The government has halted its plans to alter its withdrawal agreement with the EU, which had caused uproar after ministers admitted it would break international law.
The internal markets bill would have allowed the UK to go against the agreed treaty in a "specific and limited way" in relation to its implementation in Northern Ireland, and given the government the power to override decisions on goods travelling between Britain and Northern Ireland.
This admission by minister Brandon Lewis earlier this autumn sparked significant criticism from MPs, including comments from former prime minister Theresa May who warned the move would damage trust.
In the US it was interpreted as a potential threat to the Good Friday Agreement, with speaker Nancy Pelosi warning there would be "absolutely no chance" of a trade deal with Washington if Britain chose to override the withdrawal agreement.
Cabinet Office minister Michael Gove said the government had been worth threatening to rip up parts of the withdrawal agreement to reach this agreement with the EU.
He told the BBC: “We needed to make sure that if we didn’t secure agreement with the European Commission on these important questions that we reserve the right as a a fail safe mechanism to safeguard Northern Ireland’s position within the United Kingdom.
"That was always our aim, to safeguard the territorial integrity of our country, to make sure we protect the fact Norhtern Ireland was in the UK’s customs territory.”
The permanent secretary to the Government Legal Department, Sir Jonathan Jones, quit when the bill was introduced.
However after meetings in Brussels on Tuesday, Gove and European Commission vice-president Maroš Šefčovič – the co-chairs of the EU-UK Joint Committee – struck a fresh agreement that means Britain no longer intends to override the deal.
A joint statement said: "Following intensive and constructive work over the past weeks by the EU and the UK, the two co-chairs can now announce their agreement in principle on all issues, in particular with regard to the Protocol on Ireland and Northern Ireland."
This includes an agreement in principle covering border-control posts and entry points specifically for checks on animals, plants and derived products, export declarations, the supply of medicines, the supply of chilled meats, and other food products to supermarkets, and a clarification on the application of state aid under the terms of the Protocol.
They have also come to an agreement on finalising the list of chairs for the arbitration panel designed to resolve disagreements over the application of the withdrawal agreement.
The government has now reduced the controverial clauses from the UK internal market bill that would have broken the treaty, and said they would not not introduce any similar provisions in the taxation bill.
Gove said he was delighted with the agreement.
The move follows a late vote by MPs on Monday to re-insert the controversial clause after it was removed by the House of Lords. Tuesday's agreement prevents further parliamentary "ping pong" in which the Lords reinsert it again.
The development does not affect the Brexit trade talks which are still ongoing. Boris Johnson will travel to Brussels on Wednesday evening for a face-to-face summit with the European Commission president, Ursula von der Leyen, to try and reach a deal.
Kate Proctor is political editor of CSW's sister title PoliticsHome, where this story first appeared.