(Bloomberg) -- The Northern Ireland Protocol is valid and drawn up in line with UK legislation, the Supreme Court ruled on Wednesday in a boost to Prime Minister Rishi Sunak’s embattled government.

The UK’s top court rejected the legal challenge from a disparate group of unionist lawmakers and Brexit supporters over the contentious agreement. The protocol, put in place to avoid a land border between Northern Ireland and the Republic of Ireland, doesn’t violate the UK’s constitution and the laws that bind Northern Ireland with the rest of the UK.

The decision is a spot of welcome news for the government as it tries to renegotiate the terms of the deal. The two sides are inching closer to unlocking a comprehensive deal. A resolution would end the drawn-out dispute over the Northern Ireland Protocol, part of the wider Brexit deal signed in 2020.

The judges said the approval by the parliament as part of the Withdrawal Agreement came after “intense and protracted Parliamentary involvement” and the protocol is compatible with the UK’s laws. “The most fundamental rule of UK constitutional law is that Parliament, or more precisely the Crown in Parliament, is sovereign and that legislation enacted by Parliament is supreme.”

The deal effectively placed a frontier in the Irish Sea — allowing Northern Ireland to remain in the EU single market. But it has disrupted trade between Northern Ireland and Great Britain because of the burden of new paperwork and customs procedures. 

Anti-protocol campaigners, including two former Northern Ireland first ministers, said it was incompatible with UK law as it threatens to dismantle the union. Two previous courts had tossed the challenge.

The post-Brexit regime was agreed to allow movement of goods between Northern Ireland and Ireland, without turning their border into a soft target for smuggling goods between the UK and the EU. 

A spokesperson for the UK government said the Supreme Court was right to reaffirm the sovereignty of Parliament and the government is determined to address the problems the protocol is causing in Northern Ireland. 

“Intensive talks with the EU continue to that end, looking across the full range of issues we have raised,” the spokesperson said in an emailed statement.

The protracted negotiations over the trade regime have helped keep the politically polarizing debate simmering. The two sides, however, cleared a major hurdle in January, when the EU agreed to use the UK’s live database system that tracks goods moving between the countries.

“The protocol represents an existential threat to the future of Northern Ireland’s place within the union,” Jeffrey Donaldson, the Democratic Unionist Party Leader, said after the after the ruling. “The longer the protocol remains, the more it will harm the union itself.” 

A Sinn Fein party lawmaker took a different view:

--With assistance from Jonathan Browning and Morwenna Coniam.

(Updates with the UK government comments in the ninth paragraph.)

©2023 Bloomberg L.P.