Sir Jeremy Heywood is standing down from his role of as head of the civil service to concentrate on his recovery from cancer.
The cabinet secretary took a three month leave of absence in the summer to receive treatment for the illness and a related infection. He was replaced by Sir Mark Sedwill, the national security adviser, who has now taken on the role permanently.
Theresa May paid tribute to Sir Jeremy for his "exemplary service" during nearly 25 years in Whitehall, nominating him for life peerage in recognition for his contribution to public life.
One of Whitehall's most senior figures, Sir Jeremy discovered he had cancer last year but he continued to work during the political turmoil triggered by the snap general election, where Ms May had to scramble to make a deal with the DUP after losing her parliamentary majority.
Paying tribute, the prime minister said: “Jeremy has given exemplary service to the public in his civil service career.
"He has worked constantly to improve our country’s future and to deliver for the public, serving prime ministers and ministers of all parties with distinction in the finest traditions of the civil service.
"I am personally grateful to him for the support he has given me as prime minister. He has made an enormous contribution to public life in our country and will be sorely missed.”
As head of the civil service, Sir Jeremy was a vital player in the Brexit preparations, as Whitehall officials will have to take over duties from Brussels when Britain leave the European Union.
He was appointed cabinet secretary, Ms May's most senior policy advisor, in 2011 and became head of the civil service in 2014.
In a personal statement, Sir Jeremy said: "Thirty-five years ago, I joined the civil service as an enthusiastic young economist in the Health and Safety Executive, full of ideas and keen to make change happen.
"Today, I still have all that desire to serve my country and to make a positive difference. It is with great sadness therefore that, on medical advice, I must now retire."
He defended the civil service from "noises off" from anonymous commentators, referring to Eurosceptic critics who fear government officials would rather remain in the European Union.
Sir Jeremy said: "During my time in charge, I have encouraged the civil service to be more open, more diverse, more inclusive in its culture and more professional in all that it does.
"And, despite a number of recent “noises off” from anonymous commentators, I believe that the service is in robust health, well-equipped to provide the support the country needs over the coming months and years."
Sir Mark, 54, said: "The whole public service will want to thank Jeremy for his tireless and outstanding service to our nation, and for the values he exemplifies. He has had a profound, positive and lasting impact and will be greatly missed."
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies