LONDON — Britain and the European Union struck a landmark agreement on Monday to end a festering dispute over post-Brexit trade rules for Northern Ireland, potentially resolving one of the most poisonous legacies of Britain’s exit from Europe’s trade bloc in 2020.
The agreement, concluded after weeks of confidential talks and multiple false starts, could have far-reaching economic and political consequences: averting a trade war between Britain and the European Union, smoothing Britain’s relations with its Continental neighbors, making it simpler to ship goods between Northern Ireland and the rest of the United Kingdom, and opening the door to restoring a functioning government in Northern Ireland after months of paralysis.
It could also remove a lingering irritant between Britain and the United States. President Biden had pressed Prime Minister Rishi Sunak of Britain to negotiate an end to the impasse with Brussels, and the deal could smooth the way for a visit by the president to London and Belfast, Northern Ireland’s capital, to mark the 25th anniversary of the Good Friday Agreement, which ended decades of bloodshed known as the Troubles.
Mr. Sunak and Ursula von der Leyen, the president of the European Commission, announced the deal, which they called the “Windsor Framework,” after working out the final terms at a meeting in Windsor, outside London.
“The United Kingdom and the European Union may have had our differences in the past, but we are allies, trading partners and friends,” Mr. Sunak declared. “This is the beginning of a new chapter in our relationship.”
Ms. von der Leyen said the agreement would allow them to remove a source of friction and focus on greater challenges, including curbing climate change and defending Ukraine in its war with Russia.
Still, the deal is an acute risk for Mr. Sunak, opening him up to a backlash from Brexit hard-liners in his Conservative Party and the Democratic Unionist Party in Northern Ireland, which has campaigned to rewrite the trade rules rather than simply modify them.
The Democratic Unionists reserved judgment on the agreement, saying they needed to read the legal text. In a statement, the party’s leader, Jeffrey Donaldson, said, “It is clear that significant progress has been secured across a number of areas whilst also recognizing there remain key issues of concern.”
Northern Ireland’s trade rules, as fiendishly complex as they are, have become a totemic issue for Brexiteers and unionists because of the territory’s unique status: It is part of the United Kingdom but shares a land border with the Republic of Ireland, a member of the European Union and its single market.
The rules, known as the Northern Ireland Protocol, were negotiated as part of Brexit, Britain’s departure from the European Union three years ago. They were designed to avoid customs checks at the land border, which would be unacceptable for Ireland and for many people in Northern Ireland, particularly the nationalists, the largely Catholic part of the population that wants the territory to unite with Ireland.
But the rules alienated the unionists, the largely Protestant part of Northern Ireland that wants to remain in the United Kingdom, by creating obstacles to trade with the rest of Britain.
For Mr. Sunak, who came to power in October and is trailing the opposition Labour Party in the polls, the deal is a litmus test for his young government. A negative reaction could embolden one of his predecessors, Boris Johnson, who was ousted last year but who may harbor ambitions for a comeback.
In choosing Windsor as the site and name of the agreement, Mr. Sunak appeared to reach not so subtly for the imprimatur of King Charles III, who welcomed Ms. von der Leyen for tea at Windsor Castle after her meeting with the prime minister.
While some commentators described the king’s cameo as a show of strength by Mr. Sunak, critics said it was improper to draw the monarch, who is supposed to be above politics, into an issue as divisive as Northern Ireland.
“It’s crass and will go down very badly in NI,” Arlene Foster, Mr. Donaldson’s predecessor as the leader of the Democratic Unionists, wrote on Twitter. “We must remember this is not the King’s decision but the Government who it appears are tone deaf.”
Mr. Sunak framed the agreement as a way to reinforce the integrity of the United Kingdom and preserve the peace from the Good Friday Agreement. He promised that Parliament would have a chance to vote on the agreement, though he offered no timetable for presenting the deal to the House of Commons.
He got an endorsement from Mr. Biden, who said in a statement that the agreement was “an essential step to ensuring that the hard-earned peace and progress of the Belfast/Good Friday Agreement is preserved and strengthened.” The president also urged Northern Ireland’s leaders to get their political institutions “back up and running.”
The prime minister played up three features of the deal: a “green lane” with little bureaucracy for goods traveling from Britain to Northern Ireland that are destined to stay there; a provision allowing the British Parliament to set value-added tax and excise duties for Northern Ireland; and an “emergency brake” enabling the elected assembly in Belfast to prevent new E.U. laws on goods from being applied there.
Mr. Sunak tried to put the deal in everyday terms: no more restrictions on owners trying to move their pets from Belfast to London; the same species of trees in garden centers on both sides of the Irish Sea; and plenty of British sausages filling Northern Ireland’s grocery shelves.
The agreement does not sweep aside the protocol, as its unionist critics demanded. But it eliminates many of the bureaucratic hurdles that burdened businesses in Northern Ireland and harmed consumers because some exporters in Britain were no longer willing to fill out the paperwork to ship goods there.
“We have removed any sense of a border in the Irish Sea,” Mr. Sunak said, referring to customs checks imposed on goods traveling from mainland Britain to Northern Ireland.
Had Britain and the European Union not been able to settle their differences, some predicted it would have led to the resurrection of a hard border across Ireland, a development that could have jeopardized the Good Friday Agreement.
Fears of a new wave of violence were revived last week by the shooting of an off-duty police officer, John Caldwell, in Omagh, a town near the border. The New Irish Republican Army took responsibility for the attack. Mr. Caldwell, 48, is in critical but stable condition.
“Those trying to drag us back into the past will never succeed,” Mr. Sunak said.
Whether the agreement will be enough to restore Northern Ireland’s government, however, was not clear. To protest the protocol, the Democratic Unionists have boycotted the assembly since before legislative elections last year. To ensure that power is shared between unionists and nationalists, the system shuts down unless the largest parties on both sides agree to participate.
Some analysts said they were skeptical that the Democratic Unionists would return to the government even if they accepted the deal. In elections last May, the Irish nationalist party, Sinn Fein, emerged as the territory’s largest, which gave it the right to appoint the first minister in the government.
For its part, Sinn Fein welcomed the agreement, though it, too, said it wanted to scrutinize the fine print. “We’ve always said that it was possible to have a deal,” said Michelle O’Neill, the party’s leader in Northern Ireland.
The role of the Court of Justice of the European Union is likely to be a bone of contention. While Mr. Sunak promoted the concept of an “emergency brake” to prevent the imposition of European laws, Ms. von der Leyen left no doubt that the court would remain the ultimate arbiter of disputes in the single market. How Northern Ireland’s legislators would pull that brake without a sitting assembly was unclear.
Another key reaction will be from Conservative Brexit supporters. Mr. Sunak got a valuable endorsement from Steve Baker, an influential euroskeptic and government minister who pronounced himself “delighted” by the agreement.
But Mr. Johnson has so far been silent. He agreed to the protocol during his time in office, but later angered E.U. nations by introducing legislation intended to give the British government power to override parts of it.
That bill was being examined by the House of Lords, the unelected upper chamber of Parliament, but Mr. Sunak agreed to scrap it as a price for concessions made by Brussels. Mr. Johnson, according to British news reports, has told allies that abandoning the bill would be a “great mistake.”
Some observers believe that Mr. Johnson is preparing to destabilize Mr. Sunak’s leadership and, perhaps, to try to oust him if the Conservative Party performs poorly in local elections scheduled for May.
“He wants to bring down Rishi Sunak, and he will use any instrument to do it,” George Osborne, a Conservative and a former chancellor of the Exchequer, told Channel 4 earlier this month. “And if the Northern Ireland negotiations are that instrument, he will pick it up and hit Mr. Sunak over the head with it.”
Mark Landler reported from London, and Stephen Castle from Brussels. Megan Specia contributed reporting from London.