The government's most senior lawyer is to quit his post over plans which could modify the Brexit withdrawal agreement.
It is understood Sir Jonathan Jones, permanent secretary to the Government Legal Department, was unhappy with a new bill to be unveiled on Wednesday.
He has resigned and will leave his post before his five-year term was due to end next April.
He is the sixth senior civil servant to announce his exit this year.
BBC political editor Laura Kuenssberg said Sir Jonathan believed the plans went too far in breaching the government's obligations under international law.
A spokesman for the Attorney General's Office confirmed Sir Jonathan had resigned but did not comment further.
The Financial Times, which first reported the story, linked his departure to "suggestions that Boris Johnson is trying to row back on parts of last year's Brexit deal relating to Northern Ireland".
The newspaper added people "close to Sir Jonathan said he was 'very unhappy' about the decision to overwrite parts of the Northern Ireland protocol".
The resignation comes as the UK government is due to unveil an Internal Market Bill that could affect post-Brexit customs and trade rules in Northern Ireland.
Under the UK's exit deal, Northern Ireland is due to stay part of the EU's single market for goods in a bid to avoid creating a hard border with the Irish Republic.
In parallel with talks over a post-Brexit trade deal, the UK and EU are negotiating the precise nature of new customs checks that will be required.
International law breach
On Tuesday, Northern Ireland Secretary Brandon Lewis said the bill would provide the UK with a "safety net" in case the talks to iron out border arrangements fail.
He told MPs the bill would break international law in a "very specific and limited way" by giving UK ministers the power to override EU law in "tightly defined circumstances" if border negotiations broke down.
But he insisted the UK's "leading priority" was to try to work out the application of the protocol through negotiation with the EU.
Whether you loathe the government's abrasive style or love its ruthlessness, far from seeking a peaceful conclusion to Brexit, for No 10 there are plenty of fights still to have.
And that may mean accelerating the number of top civil servants who are cleared out - or clear off of their own volition.
Six permanent secretaries - who head government departments - have gone now.
Given the importance of the principle of the rule of law, one former permanent secretary told me Jonathan Jones' departure is "absolutely massive, by far the most important yet".
And few at Westminster believe there won't be more to come.
Sir Jonathan is the latest permanent secretary - a senior civil servant leading a government department - to leave office this year.
Rowena Collins Rice, director general at the Attorney General's Office, will also be leaving her post, the government confirmed earlier on Tuesday.
She is expected to take up a new public role. Her departure was the result of a "process dating back several months," officials said.
At the beginning of September, Simon Case was appointed as cabinet secretary and head of the civil service, after his predecessor Sir Mark Sedwill stood down.
Sir Mark's exit followed reports of tensions between him and senior members of Mr Johnson's team.
Sir Jonathan, who is a QC, was knighted in December 2019 for his legal services to the government. The honour recognised his work on constitutional issues and the EU Withdrawal Agreement.
In response to Sir Jonathan's resignation, the shadow attorney general, Lord Charlie Falconer, said he was "an impressive lawyer and a loyal civil servant".
He added: "If he can't stay in public service, there must be something very rotten about this government. This resignation indicates that senior government lawyers think that the government is about to break the law."
Liberal Democrat Brexit spokesperson Christine Jardine said it was "unsurprising" Sir Jonathan has resigned, given the government's approach.
"Any government figure of any integrity would be appalled at these plans," she added.
Dave Penman, general secretary of the FDA union - which represents senior civil servants - said both ministers and officials were obliged to uphold the rule of law.
"It's extraordinary that the government's most senior legal adviser has decided he has no choice but to resign over an issue that he presumably believes conflicts with his own and ministerial obligations," he added.