THERESA May’s Brexit plan are descending into “chaos”, the SNP claimed last night, after the UK’s ambassador to the EU unexpectedly quit ahead of critical talks in Brussels.

Sir Ivan Rogers, who was expected to play a central role in the withdrawal process this spring, resigned after falling out with pro-Brexit ministers and Tory MPs.

One of the most experienced UK diplomats in the EU, he had been branded a “gloomy pessimist” after warning ministers a post-Brexit trade deal could take a decade to finalise.

He also said European leaders believed Brexit meant the UK leaving the EU single market in favour of a free trade arrangement, according to a leaked memo last month.

Downing Street insisted Sir Ivan, who had been expected to leave his post in November, had merely gone early to allow a successor to be installed before Article 50 is triggered in March.

However opposition parties claimed his departure showed the Prime Minister’s handling of Brexit had become shambolic, with civil servants hounded out for offering honest advice, and said the loss of Sir Ivan’s influence and expertise meant a poorer Brexit deal for the UK.

Brexit supporters, meanwhile, welcomed the mandarin’s exit and called for a “tough Brexiteer” to replace him and any other diplomats who were squeamish about leaving the EU.

Sir Ivan, a career civil servant, helped conduct David Cameron’s negotiations with the EU last year ahead of the Brexit referendum, reportedly clashing with Downing Street advisers over the kind of limited deal which was on offer in Brussels - his pessimism proved largely correct.

SNP External Affairs Secretary Fiona Hyslop said: “Such a resignation at such a juncture is another deeply troubling sign for the UK's future relations with the EU, and yet more evidence of the complete chaos at the heart of the Prime Minister's position.

"If respected and experienced UK civil servants are so clearly unable to do their jobs as a result of the shambolic UK government approach, it hardly inspires confidence that the UK government will fare well in the tough negotiations that lie ahead."

Former deputy prime Minister Nick Clegg, the LibDems’ Europe spokesman, said the government’s Brexit plans had suffered a “body blow”.

Calling Sir Ivan’s advice unfailingly “objective and rigorous”, he said: “If the reports are true that he had been hounded out by hostile Brexiteers in government, it counts as a spectacular own goal. The government needs all the help it can get from good civil servants.”

Former Labour Foreign Secretary Margaret Beckett called the exit “deeply alarming” and said the UK would suffer in Brexit talks from the loss of such a well-connected ambassador.

“I think it is a crisis for the Prime Minister and for the Foreign Office,” she said.

Labour peer Lord Mandelson, a former EU Commissioner, also said Sir Ivan's resignation was "a serious loss for us in Brussels. Our negotiations... will go nowhere if ministers are going to delude themselves about the immense difficulty and challenges Britain faces in implementing the referendum decision.”

Labour MP Hilary Benn, chair of the Commons Brexit Committee, said the government now needed to “get its skates on” to handover the role to Sir Ivan’s replacement.

Charles Grant, director of the Centre for European Reform, said: “Ivan Rogers’s resignation makes a good deal on Brexit less likely. One of the very few people at the top of British government who understands the EU.”

But former Ukip leader Nigel Farage said Mrs May should welcome the resignation “with open arms” and appoint “somebody who recognises that the world has changed, somebody tough, so we can get on with Brexit".

Leave.EU chairman Arron Banks added: "This is a man who claimed it could take up to 10 years to agree a Brexit deal. He is far too much of a pessimist and yet another of the establishment's pro-EU old guard. He has at least done the honourable thing in resigning.

"It's time now for someone who is optimistic about the future that lies ahead for Brexit Britain."

Pro-Brexit Tory MP Dominic Raab said it was sensible for Sir Ivan to make way for an ambassador who would see through the Brexit talks, as “he didn’t exactly hide the fact that his heart wasn’t in Brexit, and he was due to step down in the autumn anyway”.

A government spokeswoman said: "Sir Ivan Rogers has resigned a few months early as UK permanent representative to the European Union.

"Sir Ivan has taken this decision now to enable a successor to be appointed before the UK invokes Article 50 by the end of March. We are grateful for his work and commitment over the last three years."