The UK’s ambassador to the European Union attacked the Government’s “muddled thinking” over Brexit as he resigned, a leaked message to staff has revealed.

In his shock resignation letter, Sir Ivan Rogers revealed civil servants still faced uncertainty over the Government’s Brexit plans and urged his colleagues to challenge “ill-founded arguments”.

Sir Ivan, who has been the UK’s top ambassador to the EU for three years, resigned with weeks to go before Theresa May was due to trigger the process of leaving the 28-nation bloc.

Farage calls for more resignations after Sir Ivan Rogers quits

“I hope you will continue to challenge ill-founded arguments and muddled thinking and that you will never be afraid to speak the truth to those in power,” he wrote.

“I hope that you will support each other in those difficult moments where you have to deliver messages that are disagreeable to those who need to hear them.”

Sir Ivan unexpectedly quit just months after he sparked controversy by warning the Government that a post-Brexit trade deal could take a decade to finalise, and even then may fail to get ratified by member states.

The ambassador, who was expected to continue in his role until October, said he had done all he could to contribute his experience, expertise and contacts to the team responsible for invoking Article 50 and overseeing Brexit negotiations.

“I know that this news will add, temporarily, to the uncertainty that I know, from our many discussions in the autumn, you are all feeling about the role of UKREP [the UK Representation to the EU] in the coming months and years of negotiations over ‘Brexit’,” he wrote.

“I am sorry about that, but I hope that it will help produce earlier and greater clarity on the role that UKREP should play.”

Former Ukip leader and Brexit campaigner Nigel Farage said Sir Ivan should have stepped down the day after referendum and he hoped his resignation was the start of a “real political revolution”.

“I think we should get rid of many of our ambassadors around the world,” he said on his LBC radio show.

The former permanent secretary to the Treasury called Sir Ivan’s resignation a “wilful and total destruction” of expertise amid fears he has been “hounded out” by hostile pro-Brexiteers.

Supreme Court Brexit Challenge Show all 13 1 /13 Supreme Court Brexit Challenge Supreme Court Brexit Challenge People wait to enter the public gallery outside the Supreme Court ahead of the challenge against a court ruling that Theresa May's government requires parliamentary approval to start the process of leaving the European Union, in Parliament Square, central London Reuters Supreme Court Brexit Challenge Gina Miller, co-founder of investment fund SCM Private arrives at the Supreme court in London on the first day of a four-day hearing Getty Supreme Court Brexit Challenge A man waves the EU flag in front of the Supreme Court Getty Supreme Court Brexit Challenge Satirical artist Kaya Mar poses with two of his paintings in front of the Supreme Court Getty Supreme Court Brexit Challenge Pro-Europe protestors dressed as Supreme Court Justices stand outside the Supreme Court ahead of the first day of a hearing into whether Parliament's consent is required before the Brexit process can begin. The eleven Supreme Court Justices will hear the government's appeal, following the High Court's recent decision that only Parliament can trigger Article 50 Getty Supreme Court Brexit Challenge The eleven Supreme Court Justices will hear the government's appeal, following the High Court's recent decision that only Parliament can trigger Article 50 Getty Supreme Court Brexit Challenge Businesswoman Gina Miller arrives at the Supreme Court ahead of the first day of a hearing into whether Parliament's consent is required before the Brexit process can begin Getty Supreme Court Brexit Challenge Attorney General Jeremy Wright arrives at the Supreme Court in London EPA Supreme Court Brexit Challenge Protesters outside the Supreme Court in London, where the Government is appealing against a ruling that the Prime Minister must seek MPs' approval to trigger the process of taking Britain out of the European Union PA wire Supreme Court Brexit Challenge A protesters wearing a judge's wigs and robes stands outside the Supreme Court ahead of the challenge against a court ruling that Theresa May's government requires parliamentary approval to start the process of leaving the European Union, in Parliament Square, central London Reuters Supreme Court Brexit Challenge A protester holds up a placard outside the Supreme Court ahead of the challenge against a court ruling that Theresa May's government requires parliamentary approval to start the process of leaving the European Union, in Parliament Square, central London Reuters Supreme Court Brexit Challenge Pro-Europe protestors dressed as Supreme Court Justices stand outside the Supreme Court Getty Supreme Court Brexit Challenge A man waiting to enter the public gallery waves a European Union flag outside the Supreme Court ahead of the challenge against a court ruling that Theresa May's government requires parliamentary approval to start the process of leaving the European Union, in Parliament Square, central London Reuters

Nicholas Macpherson said the ambassador was the latest in a worrying line of experienced figures to walk away.

“Ivan Rogers huge loss. Can’t understand wilful and total destruction of EU expertise,” he wrote.

Sir Ivan said unlike in Brussels, “serious multilateral negotiating experience is in short supply in Whitehall”.

“The government will only achieve the best for the country if it harnesses the best experience we have – a large proportion of which is concentrated in UKREP – and negotiates resolutely.”

He also appeared to criticise views held by politicians, writing: “Contrary to the beliefs of some, free trade does not just happen when it is not thwarted by authorities”.