London CNN  — 

The UK and the European Union reached a significant milestone in their pursuit of a Brexit deal on Friday, breaking a deadlock that allows talks to move on to a crucial second phase.

After a dramatic night of shuttle diplomacy that capped months of tortuous negotiations, European Commission President Jean-Claude Juncker and British Prime Minister Theresa May announced the breakthrough at an early morning press conference in Brussels.

Crucially, the two sides reached a deal on the historically sensitive issue of the Irish border, which had threatened to derail the talks as they reached a critical moment earlier this week. Discussions can now move on to the potentially tougher issue of a future trading relationship between the UK and the EU.

British Prime Minister Theresa May addresses the media in Brussels.

The breakthrough represents a significant coup for May, whose beleaguered premiership had appeared under threat as talks faltered. It was also a relief for EU negotiators, who feared a complete breakdown in talks if a deal was not done.

“Getting to this point required give and take on both sides,” May said. “And I believe the joint report that is being published is in the best interest of the whole of the UK.”

What has been agreed?

Agreement has now been reached on three key issues: Britain’s Brexit “divorce” bill, the rights of EU citizens in the UK after Brexit, and the Irish border. When Brexit negotiations began just under six months ago, the EU was clear on its position: It would not countenance any discussion about a future trading relationship with Britain until “sufficient progress” had been made on those three issues.

Irish border: The Irish question proved the toughest to resolve. The demilitarization of the border between Northern Ireland and the Republic of Ireland was a key element of the Good Friday Agreement, the 1998 deal that ended years of sectarian conflict in Northern Ireland. Now, the border posts are gone and people can move freely around the island of Ireland.

But Brexit raised the prospect of a return to a “hard” border, as Northern Ireland would leave the EU while the Republic of Ireland remained in the bloc.

Traffic crosses the border into Northern Ireland from the Irish Republic near Dundalk.

Complicating the issue, May’s minority government depends on the support of on a small group of 10 MPs from Northern Ireland, members of the hardline Democratic Unionist Party (DUP). They were adamantly opposed to any suggestion that, to avoid a hard border, Northern Ireland could retain laws and regulations that were more aligned to the EU than the rest of the UK.

The DUP vetoed the text of an earlier deal on Monday, just as May was having lunch with Juncker in Brussels to finalize it. She was forced to return to London as negotiators spent the rest of the week hammering out a solution acceptable to the DUP, the Irish government and the EU.

The language of the deal announced on Friday remains ambiguous. It says: “In the absence of agreed solutions, the UK will maintain full alignment with those rules of the internal market and the customs union which, now or in the future, support North-South cooperation, the all-island economy and the protection of the 1998 agreement.”

That’s a backstop. It means that, in the next stage of talks, the UK must come up with solutions that avoid a hard border, otherwise the UK will have to remain tied to EU rules even after Brexit. That scenario would enrage the ardent Brexiteers in May’s Conservative Party.