The top civil servant in the Home Office has resigned and said he intends to claim for constructive dismissal by the government.
Sir Philip Rutnam said there had been a "vicious and orchestrated" campaign against him in Home Secretary Priti Patel's office.
Reported tensions between the pair included claims she mistreated officials - which she has denied.
The prime minister has "full confidence in his cabinet", Downing Street said.
The BBC's political editor Laura Kuenssberg said Sir Philip's move was "highly unusual", adding: "I can't remember a senior public official taking a step like this."
Sir Philip said he received allegations that Ms Patel's conduct towards employees included "swearing, belittling people, making unreasonable and repeated demands".
He said that behaviour had "created fear and needed some bravery to call out".
It was his duty to "protect the health, safety and wellbeing" of 35,000 Home Office workers, he said, but that doing so had "created tension" between him and Ms Patel.
Sir Philip, who has had a career spanning 33 years, added he had attempted a "reconciliation" with Ms Patel but that she had "made no effort to engage with me to discuss this".
He said he believed his experience was "extreme" but part of a "wider pattern" in government.
Ms Patel has not yet commented on Sir Philip's statement.
Sir Mark Sedwill, cabinet secretary and head of the civil service, thanked Sir Philip for his "long and dedicated career of public service" and said Shona Dunn, who had been Mr Rutnam's deputy, will become acting permanent secretary.
He said he received the resignation "with great regret", adding: "The Home Office's vital work to keep our citizens safe and our country secure continues uninterrupted."
It comes days after the home secretary and Sir Philip released a joint statement saying they were "deeply concerned" by various "false allegations" made about Ms Patel.
Allegations the pair dismissed included reports that Ms Patel, who has been home secretary since Boris Johnson became prime minister, bullied her staff and was not trusted by MI5 bosses.
But in a statement given to BBC News, Sir Philip said: "In the last 10 days, I have been the target of a vicious and orchestrated briefing campaign."
He said allegations that he had briefed the media against the home secretary were among many "completely false" claims against him.
Sir Philip said he did not believe Ms Patel's denial of any involvement in the false claims, adding that she had not "made the efforts I would expect to dissociate herself from the comments".
Sir Philip's departure, and the manner of it, goes way beyond any normal policy problems or clashes.
He took aim not just at Priti Patel, but alluded to what he said was a "wider pattern" in government.
Add this to the resignation of Sajid Javid, the former chancellor who expressed concerns about how the government is behaving, there is mounting evidence of unhappiness with how Prime Minister Boris Johnson and his team are running things.
Certainly it is a government in a hurry, willing to rattle cages in order to get things done.
But governments who want to get things done need an effective civil service to make things happen. A very public breakdown in trust like this does not help that cause.
Indications at this early stage are that Ms Patel's position is secure. But with an employment tribunal in the offing, pressure may well build in the coming weeks.
If Sir Philip pursues his case as he says he will, exactly what happened behind closed doors may soon be out there for all to see.
Read more from Laura here.
Sir Philip said he intended to issue a claim against the Home Office for constructive dismissal.
He added that the Cabinet Office had offered him a financial settlement "that would have avoided this outcome" - but he turned it down.
For a claim of constructive dismissal to be successful at an employment tribunal, an individual must prove their employer seriously breached their contract and that they resigned in response to the breach.
Reasons for claiming constructive dismissal can include employers allowing bullying or harassment at work, or failing to support an employee in their job, according to Citizens Advice.
Lord Kerslake, the former head of the civil service, said Sir Philip's departure was "quite extraordinary" and "unprecedented".
"For him to have done this - he must have been pushed to the limit and beyond," he said.
"I think it will send shock waves through the civil service."
Jon Trickett, Labour's shadow Cabinet Office minister, said driving a professional civil servant out of office "is the clearest sign yet of the underlying right-wing, authoritarian - but incompetent - nature of the Johnson government".
"They will not tolerate dissent, yet can't cope with flooding or a possible pandemic," he said on Twitter.
Earlier this week, when a Downing Street spokesman refused to say whether the prime minister had full confidence in Sir Philip Rutnam, his departure became inevitable.
Cabinet Secretary Sir Mark Sedwill was consulted ahead of negotiations to agree a settlement. A financial package was on offer, but the stumbling block was apparently the public statement accompanying it.
Sir Philip wanted recognition for his work in Whitehall and an acknowledgement of the difficulties he'd encountered at the Home Office. According to those close to him that was not forthcoming.
Critics of the former permanent secretary claim he was sometimes obstructive and difficult to work with; some believe he was fortunate to keep his job after the Windrush affair, when Amber Rudd resigned as home secretary; a report into the scandal, to be released soon, may have put his position under further scrutiny.
Nevertheless, for one of the country's most senior civil servants to resign in such a dramatic way suggests he has concerns that go well beyond safeguarding his own reputation.
For the government, the prospect of more damaging headlines is clear: Sir Philip's statement may embolden others to come forward with concerns, while legal proceedings would mean the internal workings of the Home Office - including discussions involving Priti Patel and her advisers - being made public.
Yvette Cooper, chairwoman of the Commons home affairs committee, said it was "appalling" and reflected badly on the whole government that the situation at the Home Office was allowed to deteriorate to such an extent.
She said: "To end up with one of the most senior public servants in the country taking court action against one of the great offices of state shows a shocking level of breakdown in the normal functioning of government."
The home affairs spokeswoman for the Liberal Democrats said "serious questions" must be asked about the "culture that is being created in the Home Office".
Christine Jardine added: "The way these Conservatives are treating public servants and trying to undermine the rule of law is outrageous."
The FDA union for senior public servants said Sir Philip's resignation was a consequence of people making anonymous claims about those "who are unable to publicly defend themselves".
FDA general secretary Dave Penman said the "cowardly practice" was "ruining lives and careers" as well as diverting resources.