Britain's ambassador to the European Union has unexpectedly and abruptly resigned.

The surprise move comes just a few months before British Prime Minister Theresa May is expected to start formal negotiations on Britain's exit from the EU.

Ivan Rogers told staff this afternoon that he would step down from his post early, the Financial Times first reported.

In a lengthy farewell email to his staff posted on The Times website this evening, Mr Rogers hit out at the "ill-founded arguments and muddled thinking" of politicians.

He revealed that civil servants still do not know the Government's Brexit priorities and that "serious multilateral negotiating experience is in short supply in Whitehall" - unlike in Brussels.

And he criticised politicians and urged his civil servants to continue to challenge ministers and "speak the truth to those in power".

He wrote: "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.

"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.

"I hope that you will continue to be interested in the views of others, even where you disagree with them, and in understanding why others act and think in the way that they do.

"I hope that you will always provide the best advice and counsel you can to the politicians that our people have elected, and be proud of the essential role we play in the service of a great democracy."

A government source earlier confirmed the surprise resignation, saying it was timed to allow a replacement be appointed before Article 50 is invoked.

Ms May has said she will trigger formal Brexit talks with the rest of the EU by the end of March.

Fiona Mitchell: Happy New Brexit Year

Mr Rogers, who was appointed by former prime minister David Cameron in November 2013, is one of Britain's most experienced diplomats on EU affairs.

He provoked controversy at the end of 2016 when he privately warned that a post-Brexit trade deal could take a decade to finalise and even at that point it may not be ratified by member states.

He also told ministers in October that other EU members believe a trade deal with the UK may not be hammered out until the early to mid-2020s.

He added that European leaders believe the Brexit deal is likely to be a free trade arrangement rather than continued single market membership.

His warnings relating to the potential timeframe for a Brexit trade deal are believed to have caused relations to strain with some members of the government.

Meanwhile, his advice prompted some pro-Leave Tory MPs to label him a "gloomy pessimist".

Labour former shadow foreign secretary and chairman of the Commons Brexit Committee Hilary Benn told the BBC the resignation was "not a good thing".

Neither the British government nor the Foreign Office immediately commented on the FT report.