Spain has warned the British government that a “cliff-edge” Brexit must be avoided for Gibraltar, with negotiations over the future of the Rock said to be stalling.

The outcome of talks between Spain and the UK over the future of the British overseas territory will determine whether its residents enjoy the benefits of the transition period after Brexit, in which the UK will stay in the customs union and single market for an additional 21 months.

The other 26 member states were given a veto in April 2017 when the EU published its guidelines on the Brexit negotiations.

Madrid has maintained that veto over the last 15 months. Its minister, in a meeting last Friday with the EU’s chief negotiator, Michel Barnier, along with the other EU member states, made a prolonged intervention on the issue.

A senior EU diplomat said: “They said the talks with the UK were not going anywhere, there was a lack of engagement and they emphasised that the pressure should be maintained on the British government to talk productively with them. It was one of the reasons that the meeting on Friday was three hours long.”

Following the meeting, Barnier told reporters that along with the issue of avoiding a hard border for Ireland, and settling the rights of EU citizens living on British military bases in Cyprus, a bilateral agreement on Gibraltar was needed urgently to move ahead with a Brexit deal.

“Each of these points is necessary,” Barnier said. “I repeat necessary.”

Madrid wants joint management of Gibraltar’s airport and greater co-operation on tax fraud and tobacco smuggling in return for allowing the withdrawal agreement to cover the Rock, over which it has a longstanding territorial claim.

Spain’s key goal, however, is to strike a bilateral deal with the UK that will spread some of Gibraltar’s wealth to the surrounding Spanish territories.

Talks have been ongoing between Spanish and British officials on the issue. The UK’s ambassador to Spain, Simon Manley, recently insisted the UK government was also in daily contact with its Gibraltarian counterpart to ensure “Brexit turns out well for the Gibraltarians”. Theresa May has insisted she will not countenance Gibraltar being treated differently to the UK after Brexit.

A Spanish diplomatic source told the Guardian: “We believe it’s fundamental that both delegations – British and Spanish – redouble their efforts to find a solution.

“It would be dangerous to underestimate the need for a deal. We have to avoid a cliff edge and so we need to show that we can reach a deal.

“A deal is still possible but we’re worried about the delay. We will be redoubling our efforts over the next two months and we trust the British government will do the same.”

Spain is aware that there will be little appetite to hold up the withdrawal agreement if the future of Gibraltar is the sticking point, and is keen to strike a deal with the UK as soon as possible.

Molly Scott Cato, a Green MEP representing Gibraltar, said: “While the border in Northern Ireland has been the focus of much attention during the Brexit negotiations the other point where UK territory will touch a member state of the EU if Brexit goes ahead – Gibraltar – has been somewhat sidelined in public debate.

“The depressing reality seems to be that it is Spain that recognises the urgency of arriving at a Brexit deal and the chaos that will be caused at the border with Gibraltar if no deal is reached.

“For the sake of the thousands of loyal British citizens who live on the Rock – and who voted by 96% to reject Brexit – we need the Conservative government to crush the talk of no deal amongst the Brextremists and urgently engage in serious negotiations.”