The Gibraltar Rock is pictured from La Linea de la Concepcion near ther southern Spanish city of Cadiz on March 28, 2017.
Gibraltar, the British overseas territory on Spain's southern tip, voted by 96 percent to remain in the European Union in last year's referendum. But as Brexit looms, they say that their attachment to the United Kingdom still prevails, unlike some in Scotland who would rather remain in the European Union.

 / AFP PHOTO / JORGE GUERRERO        (Photo credit should read JORGE GUERRERO/AFP/Getty Images)
JORGE GUERRERO/AFP/Getty Images
The Gibraltar Rock is pictured from La Linea de la Concepcion near ther southern Spanish city of Cadiz on March 28, 2017. Gibraltar, the British overseas territory on Spain's southern tip, voted by 96 percent to remain in the European Union in last year's referendum. But as Brexit looms, they say that their attachment to the United Kingdom still prevails, unlike some in Scotland who would rather remain in the European Union. / AFP PHOTO / JORGE GUERRERO (Photo credit should read JORGE GUERRERO/AFP/Getty Images)
Now playing
00:59
UK, Spain reach an agreement over Gibraltar
A fireball engulfs the Al-Walid building which was destroyed in an Israeli airstrike in Gaza City, early on May 13.
AFP/Getty Images
A fireball engulfs the Al-Walid building which was destroyed in an Israeli airstrike in Gaza City, early on May 13.
Now playing
03:05
Hamas releases new propaganda video amid ongoing violence
Israeli Police
Now playing
01:00
Shocking video shows mob violence in Israel
japan coronavirus olympics Essig DNT intl ldn vpx_00004629.png
CNN
japan coronavirus olympics Essig DNT intl ldn vpx_00004629.png
Now playing
03:18
Japan nears a Covid-19 crisis. The Olympics could tip it over the edge
FILE -  In this March 25, 2021, file photo, a "No Olympics" banner is placed by protesters in Tokyo during a demonstration against the going ahead of the Tokyo 2020 Olympic and Paralympic Games. Some nurses in Japan are incensed at a request from Tokyo Olympic organizers to have 500 of them dispatched to help out with the games. They say they're already near the breaking point dealing with the coronavirus pandemic. A protest message saying that nurses were opposed to holding the Olympic went viral on Japanese Twitter recently, being retweeted hundreds of thousands of times. (AP Photo/Hiro Komae, File)
Hiro Komae/AP
FILE - In this March 25, 2021, file photo, a "No Olympics" banner is placed by protesters in Tokyo during a demonstration against the going ahead of the Tokyo 2020 Olympic and Paralympic Games. Some nurses in Japan are incensed at a request from Tokyo Olympic organizers to have 500 of them dispatched to help out with the games. They say they're already near the breaking point dealing with the coronavirus pandemic. A protest message saying that nurses were opposed to holding the Olympic went viral on Japanese Twitter recently, being retweeted hundreds of thousands of times. (AP Photo/Hiro Komae, File)
Now playing
02:03
Setbacks continue for Tokyo Olympics as Games are 10 weeks out
screengrab palestinian
CNN
screengrab palestinian
Now playing
05:21
Palestinians fight eviction from homes in East Jerusalem
CNN's Rosemary Church speaks with Dr. Mustafa Barghouti, President of the Palestinian National Initiative political party, about the intensifying violence between Israelis and Palestinians.
CNN
CNN's Rosemary Church speaks with Dr. Mustafa Barghouti, President of the Palestinian National Initiative political party, about the intensifying violence between Israelis and Palestinians.
Now playing
04:16
Palestinian politician: Israel's behavior led to this escalation
screengrab kabul bomb
Reuters
screengrab kabul bomb
Now playing
01:35
Families of schoolgirls describe anguish after blast kills dozens
Reuters
Now playing
01:12
Rare purple-pink diamond could break auction record
Now playing
01:02
See these 50,000-year-old Neanderthal skulls discovered in Italy
Rescue attempts are made as a small whale stranded in the River Thames is seen in this picture obtained from social media in London, Britain, May 9, 2021. DAVID KORSAKS @dkfitldn/via REUTERS THIS IMAGE HAS BEEN SUPPLIED BY A THIRD PARTY. MANDATORY CREDIT. NO RESALES. NO ARCHIVES.     TPX IMAGES OF THE DAY
DAVID KORSAKS @dkfitldn/REUTERS
Rescue attempts are made as a small whale stranded in the River Thames is seen in this picture obtained from social media in London, Britain, May 9, 2021. DAVID KORSAKS @dkfitldn/via REUTERS THIS IMAGE HAS BEEN SUPPLIED BY A THIRD PARTY. MANDATORY CREDIT. NO RESALES. NO ARCHIVES. TPX IMAGES OF THE DAY
Now playing
01:10
See rescue attempt of whale stranded in London's River Thames
Tariq Keblaoui/CNN
Now playing
03:46
This year Ramadan in Lebanon proves harder than ever
Spain end state of emergency coronavirus Covid-19 lok Mclean intl hnk vpx_00000905.png
Spain end state of emergency coronavirus Covid-19 lok Mclean intl hnk vpx_00000905.png
Now playing
00:58
See celebrations in Spain as coronavirus curfew ends
TikTok/angie.mcyen
Now playing
02:28
Woman wakes days after surgery with different accent
Uyghur Watson pkg
CNN
Uyghur Watson pkg
Now playing
03:55
'How can we feel safe?': Uyghur on Chinese government policy
Palestinian protesters hurl rocks amid stun grenade sparks during clashes with Israeli security forces at the al-Aqsa mosque compound in Jerusalem, on May 7, 2021. (Photo by Ahmad GHARABLI / AFP) (Photo by AHMAD GHARABLI/AFP via Getty Images)
AHMAD GHARABLI/AFP via Getty Images
Palestinian protesters hurl rocks amid stun grenade sparks during clashes with Israeli security forces at the al-Aqsa mosque compound in Jerusalem, on May 7, 2021. (Photo by Ahmad GHARABLI / AFP) (Photo by AHMAD GHARABLI/AFP via Getty Images)
Now playing
02:45
Israeli police clash with Palestinians at mosque
(CNN) —  

The UK and Spain reached an agreement Saturday over the status of Gibraltar once the UK has left the European Union.

The accord over the British territory paves the way for approval by 27 EU governments at a summit Sunday on the withdrawal terms of the UK from the bloc next year.

“I have just told the head of state, the King, that Spain has reached an agreement over Gibraltar,” Spanish Prime Minister Pedro Sanchez told reporters in Madrid.

He said the agreement excludes the territory from the general negotiation between the EU and UK and “will allow Spain to negotiate directly with the UK over Gibraltar.”

Spain “will vote tomorrow in favor of Brexit,” Sanchez said.

Gibraltar, a rocky outcrop that adjoins the southern coast of Spain, voted overwhelmingly to remain in the EU. It is surrounded by the Spanish region of Andalusia that will soon hold regional elections, and Spain’s territorial claim to Gibraltar threatened to scupper Sunday’s summit.

“The unwavering commitment of the UK that it will negotiate future trade and other arrangements with the EU that work for all of the British family of nations, including Gibraltar,” the government of Gibraltar said in a statement.

“Throughout our history we’ve stuck with Britain,” said Fabian Picardo, the chief minister of Gibraltar.

The deal of the terms of withdrawal is opposed by the minority partner in the UK government, the Democratic Unionist Party.

Historic mistake

Speaking at a DUP conference Saturday, Boris Johnson, the former UK foreign minister and a leading Brexiter, said the UK was “on the verge of making a historic mistake” and that the UK would become “rules-takers.”

“Brussels has got us exactly where they want us – a satellite state,” he said.

May agreed to accept the terms of the customs union and the regulations of the EU’s single market in the agreement she reached with the European Commission earlier this month. Critics like Johnson say this is the worst possible scenario for Britain.

Theresa May has refused to comment on whether she will resign if she loses the parliamentary vote on Brexit.
Jack Taylor/Getty Images
Theresa May has refused to comment on whether she will resign if she loses the parliamentary vote on Brexit.

Nothing in the tortured 17-month withdrawal process since the UK voted to leave the EU in June 2016 has gone smoothly, and the contested rock of Gibraltar was just the latest snag.

At the moment, the border between Spain and Gibraltar is open, but the Spanish government was concerned that would change after Brexit, affecting future trade negotiations. Spain joined the EU in 1986, 13 years after the UK, and one of the conditions of its accession treaty was a clause that agreed to the British sovereignty over the outcrop with a population of 30,000.

Under EU rules, the Brexit treaty must be approved by a “strong qualified majority” of the 27 remaining nations. Even though Spain cannot formally veto the legally binding part of the agreements, other EU governments would be reluctant to adopt it without a consensus.

Even if the agreement is approved by EU leaders on Sunday, it will still need to be voted through the UK Parliament, a ballot that is far from secured for May.