The UK's top civil servant, Sir Mark Sedwill, has confirmed he plans to stand down from the role in September.
In a letter to Boris Johnson, he said it was the right time to go as the government moved to the next phase of its coronavirus recovery plan.
His exit follows reports of tensions between him and senior members of Boris Johnson's team.
The senior civil servants' union, the FDA, said Sir Mark had been undermined in a "cowardly" way.
FDA General Secretary Dave Penman accused unnamed Downing Street officials of briefing against Sir Mark.
He added: "Not only is it a self-defeating and corrosive tactic, it's also a cowardly one, safe in the knowledge that those who are briefed against are unable to publicly respond."
He said the government would be "weaker as a result" of Sir Mark's departure.
Sir Mark's other role as national security adviser will be taken by Mr Johnson's chief Brexit adviser David Frost.
Dominic Cummings, regarded as the Prime Minister's most influential political adviser, has long called for an overhaul of the civil service.
And in a speech on Saturday, Michael Gove, attacked what he called "group think" within its ranks.
As cabinet secretary, Sir Mark advised the PM on implementing policy and the conduct of government.
A career diplomat, he served as Ambassador to Afghanistan during a 20-year career in the Foreign Office. He took over as cabinet secretary at short notice following Sir Jeremy Heywood's death in November 2018.
He had previously worked alongside former PM Mrs May as the most senior civil servant in the Home Office.
After he leaves government service in September, Sir Mark will be made a peer while he will also chair a new panel on global economic security when the UK assumes the presidency of the G7 economic group of nations.
A number of top civil servants have either left their posts or are set to depart in the coming months after the Conservatives' resounding election victory in December.
Philip Rutnam is suing the Home Office for unfair dismissal after quitting in February while Simon McDonald is leaving the Foreign Office in September following its merger with the Department for International Development.
Sir Mark said he had served both Mr Johnson and his predecessor in "extraordinary times".
"Two years ago, when my predecessor fell ill, your predecessor asked me to step in as Cabinet Secretary, and you asked me to continue to support you through Brexit and the election period," he wrote.
"It was obviously right to stay on for the acute phase of the Covid-19 crisis. As you are setting out this week, the government's focus is now shifting to domestic and global recovery and renewal."
There have been no secrets about the government's ambition to shake up how it does business.
And there has never been any mystery about the desire of the prime minister's top adviser, Dominic Cummings, to change Whitehall.
What might perhaps have been rather abstract and hypothetical is becoming real.
Because it doesn't just matter who the politicians are that set the direction of the government. It's not just important who their unelected advisers are who suggest, cajole and promote their ideas.
The officials who are charged with carrying out their agendas are crucial, too.
The departure of Sir Mark Sedwill, therefore, matters. The cabinet secretary is the boss of thousands and thousands of civil servants, and holds the ultimate responsibility for making the government machine work. And he is the third senior official to have called it quits on Boris Johnson's government.
In response, Mr Johnson said Sir Mark made a "massive contribution" to public life over the past 30 years and had been a source of "shrewd advice".
"You have done it all in Whitehall: from Afghanistan to the modernisation of the civil service; from immigration policy to Brexit and defeating coronavirus," he said.
"After serving for decades with great distinction - and unflappable good humour - I believe you have earned the gratitude of the nation."
Labour's shadow cabinet minister Helen Hayes paid tribute to Sir Mark, saying he had performed with dedication in "difficult times".
But she added: "On the day it was revealed millions of jobs across the country could be under threat in the coming months, it is very concerning Boris Johnson and Dominic Cummings are preoccupied with reshuffling Whitehall."
No 10 said Mr Frost would succeed Sir Mark as national security adviser, also taking a seat in the Lords, but he would continue to oversee negotiations on a trade deal with the EU until their conclusion.