Spain has warned it could derail the Brexit deal agreed between London and Brussels if it does not guarantee Madrid's veto over Gibraltar's future status.

Madrid has a long-standing claim on Gibraltar, which was ceded to the British crown in the 1713 Treaty of Utrecht.

Britain's Prime Minister Theresa May is due to sign a treaty with European Union leaders to leave the bloc on Sunday, if Spain does not stand in the way.

Spain's Foreign Minister Josep Borrell warned after a meeting of EU ministers that the draft deal does not spell out how Gibraltar should be handled.

He said the text does not make it clear that future negotiations on ties between Brussels and post-Brexit Britain are separate from the Gibraltar issue.

"Future negotiations on Gibraltar are separate negotiations. And that is what needs to be made clear," Mr Borrell said.

"Until it is clear ... we will not be able to give our agreement", he warned.

In response, the British government has said the draft Withdrawal Agreement covers Gibraltar.

A statement from the government of Gibraltar said the Chief Minister was in touch with Mrs May following Mr Borrell's comments.

The statement says Mrs May was clear that the UK will not exclude Gibraltar from negotiations on the future relationship with the EU.

According to Article 184 of the draft divorce deal, "the EU and the United Kingdom shall make every effort, in good faith and with full respect for their respective legal systems, to adopt the measures necessary to negotiate rapidly the agreements governing their future relationship."

These agreements will be negotiated between Brexit day on  29 March 2019 and December 2020 - extendable once - and will enter into force at the end of the period.

Spain wants to retain what it sees as its right to negotiate the future on Gibraltar with Britain on a bilateral basis, giving it an effective veto.

Earlier, the EU’s chief Brexit negotiator Michel Barnier has said the UK government’s draft Brexit deal was "fair and balanced".

Mr Barnier told a news conference after briefing the 27 national EU ministers that they generally approved of the draft agreement reached last week.

He said that a blank in the document on the end-date for a possible extension of the status-quo transition period should be resolved before Sunday’s summit.

"We are in fact at a decisive moment in this process, no one should lose sight of the progress that has been achieved in Brussels and in London," Mr Barnier said. "The deal is fair and balanced."

"In particular, member states support the draft withdrawal agreement. The EU side will still have to decide the internal process for agreeing to extend the transition period."

The transition period is intended to keep post-Brexit Britain subject to EU rules - but without a vote - for long enough to allow details of their future relationship to be negotiated.

Mr Barnier said any extension would only be a one-off and must be clearly limited in time.

He said the UK would have to make appropriate contributions to EU coffers if it were to stay in the bloc's customs union and single market beyond the currently envisaged end of the transition period at the end of 2020 - 21 months after Brexit.

Under the draft withdrawal agreement published last week, the transition period would begin when the UK leaves the EU on 29 March 2019 and run until 31 December 2020.

British Prime Minister Theresa May said she wanted any post-Brexit transition phase to have ended by the time the country is due to hold a national election in 2022.

"I think it is important that in delivering for the British people we are out of the implementation period before the next general election," Mrs May said in a speech to business leaders in London.

Austrian minister for Europe Gernot Blumel said the EU27 agreed not to reopen talks on the draft deal ahead of its signing on Sunday.

Read more:
Ombudsman calls for publication of key Brexit report on NI
UK ministers to meet over renegotiating Brexit deal
More Brexit stories

During the transition, EU law will continue to apply in the UK, which will continue to participate in the customs union and the single market.

There is a one-off option for the UK to seek an extension of the transition if negotiations on the future relationship are still continuing.

The UK has been saying any extension would only be "a matter of months" but has also sought to keep it open for now.

Mr Barnier insisted that a latest end-date would be agreed this week.

He declined to comment on remarks by diplomats that a final end-date of 31 December 2022, was being discussed by EU negotiators.

EU diplomats have said that appears the latest that Brussels and the member states could accept.

However, adding that date in the treaty, even as a hypothetical last resort, could anger the Brexit supporters whose votes British Prime Minister Theresa May needs to pass the deal in parliament.

Mr Barnier said the intention remained to negotiate a future accord during the transition period that would provide the "free trade area" Mrs May had asked for as well as arrangements that would avoid a "hard border" between Ireland and Northern Ireland, on Britain's only future land frontier with the EU.

Last month, Mrs May confirmed she was ready to consider a delay of "a matter of months" in the UK’s final departure from the EU in order to avoid a hard border in Ireland.

She had previously said she did not expect any extension of the transition period to be needed, because she hoped to conclude a deal on the UK's future trade and security relationship with the EU by its scheduled end-date of December 2020.

Any extension to the transition period would be mutually agreed between the UK and the EU.

At Westminster, Brexit supporters could view extending the period as a concession to Brussels.