Cabinet Secretary Simon Case has announced he will step down by the end of the year on health grounds.
The top civil servant had been undergoing medical treatment for a "neurological condition" over the last 18 months.
In a statement he said "whilst the spirit remains willing, the body is not," adding that the decision was "solely to do with health and nothing to do with anything else".
A recruitment process for the next cabinet secretary has begun.
His role is already being advertised on the civil service website, with a salary of £200,000.
Case, 45, informed Sir Keir Starmer on Monday morning of his decision.
The prime minister later thanked him for his "support" and "years of service to our country".
"I have been very fortunate to be able to draw on Simon's advice in my first weeks and months as prime minister and so I know that we are losing a public servant of the highest calibre," he said in a statement.
"By any measure, he has made a distinguished contribution to our nation, and for that he has our sincere gratitude."
Case began his role in September 2020, after being appointed by Boris Johnson, and is now serving his fourth prime minister.
In his letter announcing his resignation, he said it had "been an honour to serve two sovereigns, four prime ministers and over 120 cabinet ministers in this role".
He went on to say "the world is changing fast and so must the civil service".
Case has at times been a controversial figure, facing scrutiny over his role in the Downing Street Partygate scandal and over messages he exchanged with ministers during the pandemic.
More recently there have been reports of tensions at the heart of No 10 between Case and the prime minister's chief of staff, Sue Gray.
Case, who was was initially put in charge of the Partygate inquiry after the first reports about parties in government offices emerged in 2021, was replaced by Gray after it emerged a gathering had taken place in his own office in December 2020.
Case told MPs he had not received a fine himself, and no-one else had been fined for the event held in his office.
He also told colleagues in private that Boris Johnson could not lead the country at the height of Covid pandemic, adding that the former PM made governance "impossible".
In a letter leaked earlier this month, Case said the previous Conservative government’s failure to hold a spending review in its final years in office had contributed to uncertainty over the public finances.
He denied allegations by the Conservatives that the new government’s claims to have inherited an economic "black hole" were bringing the civil service into "disrepute".
In October last year, Case announced he was taking time off because of a private medical matter, and he was widely expected to leave the civil service in the coming months.
A Cambridge graduate with a PhD in political history, Case ascended through the ranks of the civil service after joining in 2006.
He held roles in the UK's intelligence agency, GCHQ, and in the Royal Household on the way to the top job.
He was part of the team involved in the Brexit talks but left in 2018 to become Prince William's private secretary - a job which left him negotiating a very different exit as Prince Harry and his wife Meghan sought to step back from life as senior royals.
At the age of 41, he became the youngest cabinet secretary in more than 100 years.
The cabinet secretary is the most senior civil servant and involves advising the prime minister, leading implementation of the government's policies and managing other high-level civil servants.