Spain and Britain reached a preliminary agreement on Thursday to keep the Gibraltar land border open, just hours before Britain’s full exit from the European Union, Reuters reports.

As part of the agreement, Gibraltar, a British Overseas Territory located on Spain’s southern tip, will remain part of European Union agreements such as the Schengen area, Spanish Foreign Minister Gonzalez Laya said.

All the details of the agreement will be settled between Spain and Britain during a six-month transition regarding the territory, she told reporters.

Gibraltar was not part of a last-minute deal for Britain’s post-Brexit relationship that was reached between Britain and the European Union last week.

Without Thursday’s agreement, tens of thousands of Spaniards and Gibraltarians who cross everyday would have been forced to go through checks and passport stamping, the Spanish foreign minister said.

Spain claims sovereignty over the port at the mouth of the Mediterranean that it ceded to Britain in 1713 after a war.