LONDON — The United Kingdom and the European Union announced Thursday they had agreed to a new Brexit divorce deal, a potentially key breakthrough ahead of the Oct. 31 deadline for Britain to leave the bloc.

European leaders unanimously endorsed the deal later Thursday at the start of a summit in Brussels, but it must still be ratified by lawmakers in the British Parliament.

And that appears a particularly onerous task for Prime Minister Boris Johnson, who is set to put his deal to a rare weekend vote in the House of Commons on Saturday.

We’ve got a great new deal that takes back control — now Parliament should get Brexit done on Saturday so we can move on to other priorities like the cost of living, the NHS, violent crime and our environment #GetBrexitDone #TakeBackControl — Boris Johnson (@BorisJohnson) October 17, 2019

The prime minister told reporters that it was "a very good deal both for the E.U. and for the U.K." and urged British lawmakers to "get this excellent deal over the line and to deliver Brexit without further delay."

However it has already been rejected by the Democratic Unionist Party — a Northern Irish group that has acted as a parliamentary ally to Johnson's Conservatives.

"The proposals are not, in our view, beneficial to the economic well being of Northern Ireland and they undermine the integrity of the" U.K., the DUP said in a statement.

A key player in these talks, the party disagrees with how Johnson's deal seeks to resolve the problem of Northern Ireland, which has remained an insurmountable stumbling block throughout the chaotic Brexit process.

European Commission President Jean-Claude Juncker and Britain's Prime Minister Boris Johnson gave a joint press conference Thursday. Francois Lenoir / Reuters

This will make getting the deal through Parliament even harder.

Johnson needs the DUP's backing because his Conservative Party does not have enough parliamentary seats to govern alone. Now, he may have to look to moderate Conservatives — several of whom were kicked out of the party for opposing his Brexit strategy — and even members of the opposition Labour Party.

Labour leader Jeremy Corbyn quickly released a statement saying his party would not support Johnson's plan.

"From what we know, it seems the prime minister has negotiated an even worse deal than Theresa May's, which was overwhelmingly rejected," he said.

The possible breakthrough came after negotiators from the U.K. and Europe have been hunkered down in talks inside Brussels' imposing, modernist Berlaymont building.

Both sides hope that the deal, which looked unlikely just days ago, will break the deadlock that has paralyzed British politics since the country voted to leave the E.U. in a June 2016 referendum.

"Discussions over the past days have at times been difficult. But we have delivered, and we have delivered together," the E.U.'s chief Brexit negotiator, Michel Barnier, told reporters.

However, on the subject of whether the deal could win the support of British lawmakers, he was noncommittal.

"I've done my work, my team have done their work," he said. "But the House of Commons will have to take that decision, as is their responsibility."

Johnson has staked his leadership on a promise to leave the E.U. on the current Oct. 31 deadline with or without a deal.

But rebel lawmakers passed a law forcing him to seek an extension if a deal had not been agreed to by next Saturday, in an effort to prevent a "no-deal Brexit" that could have devastating consequences for the country.

At this weekend's parliamentary session, the prime minister will likely need to convince some of his opponents that his Brexit plan is better than the alternatives: Keep delaying the process, risk crashing out of the union without a deal at all, or cancel Brexit altogether.

The prime minister has already been dealt a series of defeats in Parliament and saw his efforts to shut it down in order to force through his hard-line Brexit plans ruled unlawful by the U.K's Supreme Court.

His predecessor, May, failed on three occasions to win support for a deal she had agreed with the E.U., leading her to resign earlier this year.