The UK's ambassador to the EU urged British colleagues in Brussels to challenge "muddled thinking and... speak truth to power" as he quit ahead of Brexit talks, it has emerged.
Writing to staff, Sir Ivan Rogers said ministers needed to hear "unvarnished" and "uncomfortable" views from Europe.
Earlier it emerged Sir Ivan would be leaving his post several months early.
The government said he had quit so a successor could be in place before Brexit negotiations started.
Sir Ivan's note to staff, obtained by the BBC, confirmed this but also warned the "government will only achieve the best for the country if it harnesses the best experience we have".
Downing Street said it would not comment on the resignation email, although Sir Ivan was "free to express his own opinions".
But former Conservative leader Iain Duncan Smith, who campaigned for Leave during the referendum, told BBC Radio 4's Today programme that when a civil servant "starts going public", ministers "can no longer trust that individual".
Guy Verhofstadt, the European Parliament's chief Brexit negotiator, tweeted: "Best Wishes to Sir Ivan Rogers, a much-respected UK civil servant in Brussels - who knew what he was talking about."
By James Landale, BBC diplomatic correspondent
Outgoing ambassadors often write valedictory notes but few are as explosive as this. Sir Ivan does not name names but his remarks do not need much decoding.
The clear implication is that the advice the UK's ambassador to the EU has been giving has fallen on deaf ears in Downing Street.
And this is why he is standing down, depriving the government of one of its most experienced Brussels hands just weeks before negotiations over Brexit are due to begin.
His resignation took Downing Street by surprise, coming some eight months before his job was due to end or be extended.
So the hunt is now on for an envoy who can speak truth to power while retaining the confidence of Downing Street, who knows Brussels but is not seen as being part of Brussels.
Sir Ivan is expected to stay on for a few weeks while such a diplomatic paragon is found.
Sir Ivan, who had sparked criticism from some MPs by warning ministers a UK-EU trade agreement might take 10 years to finalise, was due to leave his post in October.
Brexit campaigners welcomed his early departure, while pro-EU politicians said it was a blow to the government's negotiations.
In his note, Sir Ivan said: "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."
He said the government would only succeed if it "negotiates resolutely", adding, in a reference to the remaining 27 EU states: "Senior ministers, who will decide on our positions, issue by issue, also need from you detailed, unvarnished - even where this is uncomfortable - and nuanced understanding of the views, interests and incentives of the other 27."
The nature of the UK's trading relationship with the EU has been much debated ahead of the formal talks.
Sir Ivan said that "contrary to the beliefs of some, free trade does not just happen when it is not thwarted by authorities", adding that market access would depend on the terms of the deals struck.
The diplomat also made clear that the timing of his resignation was designed to avoid disruption by leaving later this year when his term of office was expected to expire.
"It would obviously make no sense for my role to change hands later this year," he said.
Sir Ivan's resignation comes after his deputy in Brussels, Shan Morgan, announced in November that she would be leaving the post to become the Welsh government's permanent secretary.
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."
Mr Duncan Smith said Sir Ivan "knew very well what he was doing" when he sent the note.
He added: "It gets to a point when a civil servant starts to go public on stuff that you as ministers can no longer trust that individual.
"You must have absolute trust and cooperation. You cannot have this stuff coming out publicly."
Mr Duncan Smith also said: "There are plenty of other civil servants who didn't behave like this."
Shadow international trade secretary Barry Gardiner said government policy "appears to be to shout down anyone who tells them things they don't want to hear".
The Labour MP told BBC Breakfast: "I regret that. I think often when you shoot the messenger you end up shooting yourself in the foot and think the government needs to be careful now in ensuring that we have the experience that is required in order to conduct successful negotiations."
He said the government needed to know the "reality of the other side of the negotiations" and take it on board and negotiate the best Brexit deal for the UK.
Mr Gardiner said it was "dangerous" for the government to "rubbish" those with concerns and it was important that Sir Ivan's successor was someone with an equally distinguished record.
He said attempts to politicise the impartiality of the civil service was "really scandalous" and there was a need to recognise the experience that civil servants have.
Liberal Democrat leader Tim Farron said Prime Minister Theresa May was "marching ahead without a plan or even a clue".