Boris Johnson’s controversial legislation to override post-Brexit rules on Northern Ireland has been dumped by Rishi Sunak after he negotiated a new deal with the European Union.

Brussels agreed in turn that it will scrap its legal action against the UK, launched in retaliation over the former prime minister’s Northern Ireland Protocol Bill.

Mr Sunak confirmed the move and told MPs that his new deal “puts beyond all doubt that we’ve now taken back control”, echoing Mr Johnson’s slogan.

Mr Johnson had been warning his successor that scrapping the legislation would be a “great mistake”.

But Mr Sunak said his new “Windsor Framework”, finalised with European Commission president Ursula von der Leyen on Monday, means there is no longer legal justification for the Bill.

He told the Commons Mr Johnson’s legislation kept the UK under the jurisdiction of the European Court of Justice, “leaving us open to months, maybe years, of uncertainty, disruption and legal challenge”.

The Prime Minister said he will publish new legal advice saying the new deal means the original justification has “now fallen away”.

“In other words, neither do we need the Bill, nor do we have a credible basis to pursue it,” he said.

The commission welcomed the UK agreeing to let the Bill, currently stalled in the House of Lords, to lapse at the end of the parliamentary session.

“These arrangements, when implemented, mean that there will no longer be grounds for the existing Commission legal proceedings against the United Kingdom relating to the Protocol on Ireland/Northern Ireland,” a statement said.

Some had interpreted recent remarks from Home Secretary Suella Braverman, a senior Eurosceptic, as support for Mr Johnson’s backing of the protocol Bill.

But, according to Downing Street, she “congratulated” Mr Sunak and said the new “Stormont brake” giving the UK a veto over EU law in Northern Ireland is “an important measure to help safeguard sovereignty”.

Attorney General Victoria Prentis told the Cabinet the legal basis of Mr Johnson’s legislation had fallen away now a new deal had been negotiated with the EU.

“She said the Northern Ireland Protocol Bill was not a permanent solution and would still leave the jurisdiction of the European Court of Justice unaffected in international law,” according to the Prime Minister’s official spokesman.

“She added that the legal basis of the bill, the doctrine of necessity, had now fallen away thanks to the successful negotiation of the agreement.”

Former Cabinet minister Jacob Rees-Mogg had also backed Mr Johnson’s call, saying the Northern Ireland Protocol Bill had the support of Mr Johnson, who he described as “the person who had a mandate from the British voters”.