Image copyright AFP Image caption The UK prime minister welcomed a "new dynamic" in the talks

EU leaders have approved guidelines for the negotiation of future relations with the UK after Brexit.

The text on trade, security and other issues was agreed in "less than half a minute", clearing the way for the next phase of Brexit talks to get under way.

The UK is due to leave in March 2019 and negotiators have said they want a deal in place by the end of the year.

Prime Minister Theresa May said she believed there was a new "spirit of co-operation and opportunity".

The formal adoption of the guidelines, although widely expected, is seen as another key step as the Brexit process gathers momentum.

The guidelines give chief negotiator Michel Barnier the mandate to talk directly to the UK about the future relationship with a view to reaching a broad political agreement by October to allow the EU and UK parliaments time to consider it.

European Council President Donald Tusk said the "positive momentum" should be used to settle outstanding issues like avoiding a hard border in Northern Ireland.

EU leaders will decide in June whether the "Irish question" has been resolved and will look into a "common declaration on our future", he added.

Mrs May, who was not present when her colleagues met to discuss Brexit, said she believed there was a "new dynamic" in the negotiations.

"I believe we are approaching this with a spirit of co-operation, a spirit of opportunity for the future as well, and we will now be sitting down and determining those workable solutions for Northern Ireland, but also for our future security partnership and economic partnership," she said.

"I believe it is in the best interest of both the UK and the EU that we get a deal that actually is in the interests of both."

The new guidelines: the key bits

By the BBC's Europe reporter Adam Fleming

Image copyright AFP Image caption EU leaders have given their chief negotiator Michel Barnier a mandate to talk about trade

While welcoming the progress so far, there is a reminder that there is no legal certainty, including over the transition deal, until the whole agreement is ratified.

Last-minute wrangling by Spain has led to the inclusion of a reference to the EU's position on Gibraltar. It says that Spain and the UK have to reach a separate deal over it.

The EU's big offer is a close future relationship based on a free trade agreement with no tariffs on goods and a close partnership on security and defence, both of which the UK wants.

The UK's "red lines" will limit the closeness of the future relationship. A sentence says Brexit will cause economic consequences for both sides, which was tweaked to specify the UK would be the worse off.

What has been dubbed the "evolution clause" indicates that the EU will reconsider its offer to Britain if the UK government compromises on its red lines, such as by remaining in the customs union.

The EU fears competition from the UK and is demanding a "level playing field" between the two - including ways to prevent potential undercutting on tax, environmental and labour standards.

While not directly mentioning financial services, the EU says it will jealously guard its financial stability.

The remaining 27 leaders have also endorsed an agreement reached earlier this week on a 21-month transition period between March 2019, when the UK officially leaves, and the end of 2020.

During that period, the UK will be able to negotiate, sign and ratify its own trade deals, while EU citizens arriving in the UK will enjoy the same rights and guarantees as those who arrive before Brexit.

'Reckless' red lines

A solution to avoid a hard border on the island of Ireland has yet to be agreed, with the EU insisting on a "backstop" option of Northern Ireland, in effect, remaining in the customs union.

Irish Prime Minister Leo Varadkar said he wanted an agreement that keeps the UK "as close as possible" to the EU in order to protect trade and jobs.

But Labour, which supports staying in the customs union, said the UK and EU were a "very long way away" from achieving this at the moment and the PM needed to "finally drop her reckless red lines".

Meanwhile, EU leaders are calling for reciprocal access to UK fishing waters and stocks to be maintained after the end of the transition period.

Asked whether he thought the UK would agree to this, European Commission President Jean-Claude Juncker told BBC Scotland this was the EU's "working basis".

"We are in ongoing discussions with the UK - to try and bring them (to) where we are and they are trying to bring us (to) where they are," he said.

The UK has already agreed to abide by the rules of the Common Fisheries Policy during the transition, sparking anger among fishing groups which want full sovereignty over UK waters upon Brexit.