Boris Johnson reached a compromise with Tory rebels on Wednesday night by agreeing to give them a final say on overriding the Brexit divorce deal – but it came too late to prevent one of his senior law officers from resigning.
Officials had hoped to persuade senior legal adviser Lord Keen to change his mind after he tendered his resignation on Wednesday morning.
However, his position was unchanged after Mr Johnson promised to impose "extra parliamentary scrutiny" on the controversial Internal Market Bill by accepting an amendment similar to one from senior backbencher Sir Bob Neill.
Lord Keen, Scotland's advocate general, said he had "found it increasingly difficult to reconcile" his obligations as a lawyer with provisions in the Internal Market Bill.
He wrote in his resignation letter to the Prime Minister that he struggled to find a “respectable argument” to justify Mr Johnson’s plans. “Over the past week I have found it increasingly difficult to reconcile what I consider to be my obligations as law officer with your policy intentions with respect to the UKIM Bill,” he said.
Meanwhile, Tory rebels said they had forged the "main outline" of their deal during a "constructive" meeting with Mr Johnson ahead of the initial Commons vote on Monday night (watch the result being declared in the video below).
Sources suggested the new amendment was "almost identical" to Sir Bob’s, which seeks to stop the Government from breaching international law without a vote.
One of the Tories in the meeting said: "The Prime Minister, very early on, saw that there was a way we could work together on this, and talks have been constructive. He was listening particularly hard to concerns raised about the UK's international standing and realised early this amendment was a good compromise."
The agreement was finalised on Wednesday when MPs met Mr Johnson in his Commons office. One of the Government's leading Brexit advisers, Oliver Lewis, is understood to have played a key role in brokering an agreement with MPs.
Downing Street said the amendment would provide a "more explicit democratic mandate" and added "legal certainty". It is also understood to add an extra layer of protection against judicial review.
In a joint statement with Sir Bob, a Number 10 spokesman said: "We welcome the way the Parliamentary party has come together on these issues. There is near-unanimous agreement that the Government must be able to use these powers as a final resort, that there must be legal certainty, and that no further amendments are required on these powers."
The shadow business secretary, Ed Miliband, said the resolution would not "fix the problem of breaking the law, damaging our reputation around the world and damaging our future prosperity".
"On the basis of tonight's statement, this Bill still breaks international law, reopens the Brexit debate, and Labour will continue to oppose it," he added.
Lord Keen tendered his resignation on Wednesday as Brandon Lewis, the Northern Ireland Secretary, effectively accused him of misleading the House of Lords.
The peer had said on Tuesday that it was the Government's view that the controversial legislation did not contravene international law and that Mr Lewis had "answered the wrong question" when he said it did (see video below).
However, Mr Lewis doubled down on his initial statement on Wednesday, telling the Northern Ireland select committee his words were a "very straight answer" which was "absolutely in line" with legal advice.
In a letter to the Prime Minister, Lord Keen wrote: "Your Government faces challenges on a number of fronts and I fear that the UKIM Bill in its present form will not make these any easier."
Responding to the resignation, Labour's shadow attorney general, Lord Falconer, said: "This has been a week of chaos from the Government's own law officers, whose legal advice has been renounced by their own Government. The voice of the law officers has been muted, and their authority is completely shot.
"This has been a farce that shames the entire Government."