MADRID -- An 11th-hour breakthrough in protracted negotiations will keep open Gibraltar's crucial border with Spain following the United Kingdom's full departure from the European Union, Spanish Foreign Minister Arancha Gonzalez Laya announced Thursday.
Just hours before the U.K. was to complete its break from the 27-nation bloc, Madrid and London clinched "an agreement in principle" that means people in the speck of British territory on Spain's southern tip "can breathe a sigh of relief," Gonzalez Laya said.
The key to the deal is that The Rock, whose sovereignty is disputed by Spain and Britain, will remain subject to rules in use in Europe's Schengen area, she said. That area consists of about two dozen nations that have agreed to eliminate general travel checks among them. Britain is not in the Schengen group.
British Foreign Secretary Dominic Raab said in a statement the negotiating teams wanted to "ensure border fluidity, which is clearly in the best interests of the people living on both sides."
The compromise agreement between Spain and the U.K. will be sent to Brussels, where the European Commission will enter into negotiations with London to turn it into a treaty, Gonzalez Laya said.
She said she expected the treaty to be signed within six months.
The head of Gibraltar's government, Fabian Picardo, warned that there were still tough negotiations ahead in drawing up the treaty, including jurisdiction issues and import duties.
"There will be complexity to come," he told a news conference, adding that "we may end up with a deal on the (free) movement of people but not goods."
Gonzalez Laya said the agreement's technical details, such as how Gibraltar's port and airport will be policed, will be published in the new year. A major hurdle in the negotiations was whether EU representatives could be stationed in the British territory.
Spain is to ensure that Gibraltar abides by Schengen rules.
In the U.K.'s 2016 Brexit referendum, 96% of voters in Gibraltar supported remaining in the EU. They faced the possibility of entering the new year with tight new controls on what for decades has been an open border with the bloc through Spain.
A lot was riding on the outcome for Gibraltar, which needs access to the EU market for its tiny economy. The territory is home to around 34,000 people.
More than 15,000 people live in Spain and work in Gibraltar, making up about 50% of its labour market.
Gibraltar wasn't part of the Brexit trade deal between the EU and the U.K., which was announced on Christmas Eve.
The territory was ceded to Britain in 1713, but Spain maintains its claim to sovereignty over it. That dispute has occasionally flared.