Image copyright EPA

Theresa May will return to Brussels for Brexit talks this weekend as the UK and EU strive to do a deal in time for Sunday's summit of European leaders.

After a two-hour meeting with EU officials, the prime minister said progress was being made on the future shape of EU-UK relations.

Spain has said it will not agree to the Brexit deal unless changes are made to the wording over Gibraltar.

But No 10 sources said they expected a solution before Sunday's gathering.

Sources said the announcement that the PM would make an unscheduled trip to Brussels on Saturday did not signal "major problems" over a document setting out the UK's future relations with the EU.

Mrs May spoke to Spanish Prime Minister Pedro Sánchez on Wednesday evening and said discussions would continue following "good engagement" between the countries and the government of Gibraltar, according to a Downing Street spokesperson.

London and Brussels have already agreed the draft terms of the UK's exit from the EU on 29 March 2019 - a 585-page document covering citizens' rights, financial issues and the Irish border.

Some Tory MPs want what BBC political editor Laura Kuenssberg described as "nips and tucks" to this legally-binding agreement, but the UK and EU have signalled there will be no major changes.

The EU is now in a race against time to complete the text of an accompanying declaration on its future relations with the UK, covering trade, security and other issues, amid concerns from several member states.

The latest draft of this document, known as the political declaration, has just been published and is being considered by member states.

German Chancellor Angela Merkel has indicated she will not attend Sunday's meeting of European leaders - which has been called to approve both the declaration and the withdrawal deal - unless the text on future co-operation is agreed in advance.

The EU had hoped to agree on the text of the political declaration, which is not legally binding but will be the starting point for future negotiations, on Tuesday.

The BBC understands the "real deadline" in Brussels to settle it and thus ensure Sunday's summit goes ahead is now considered to be Friday morning - when ministerial negotiators meet.

After an hour of talks with European Commission President Jean-Claude Juncker on Wednesday, Mrs May sought to strike an upbeat note but signalled talks were set to continue until the eve of Sunday's summit.

"We've made further progress and as a result we have given sufficient direction to our negotiators, I hope, for them to resolve the remaining issues and that work will start immediately," she said.

"I now plan to return for further meetings on Saturday to discuss how we can bring to a conclusion this process and bring it to a conclusion in the interests of all our people."

What is the political declaration?

Under the terms of the draft withdrawal agreement, there will be a 21-month transition period after the UK leaves lasting to the end of 2020.

The future relations document sets out the basis for economic, security and defence co-operation from the start of 2021 onwards.

The UK has said it hopes to agree a trade deal by then although most observers believe it will take much longer, based on other trade agreements.

Please upgrade your browser Your guide to Brexit jargon Enter the word or phrase you are looking for Search

When it was first published last Wednesday, the document was just seven pages long and has since been extended to 20 pages.

In a statement on Wednesday, the UK said its objectives included a free-trade area for goods with zero tariffs on UK products, an end to membership of the Common Agricultural Policy and the Common Fisheries Policy and "ambitious arrangements for trade in services".

What is holding up the agreement?

The French, Dutch and Danish governments are concerned about the amount of access their fishing fleets will get to British waters.

There are broader concerns about what the Brexit agreement will mean for the future of the single market, if the UK ends up enjoying preferential access to EU markets but does not have to comply with freedom of movement rules.

Media playback is unsupported on your device Media caption Reporter Gavin Lee visited Gibraltar in April to ask: "Does Brexit put the Rock in a hard place?"

The other major issue is the future of Gibraltar, the British overseas territory which Spain has long laid claim to.

Spain is insisting that the texts state clearly that any future trade agreements between the EU and the UK will not cover the disputed peninsula and the UK would have to hold direct negotiations with Madrid over how they applied to Gibraltar.

While Spain cannot explicitly veto the deal on Sunday, the EU hopes to proceed by consensus and the BBC's Europe correspondent Damian Grammaticas said it would be politically problematic for other EU countries to press ahead without Spain's support.