This gives Spain, which resents Britain's three-century-long occupation of Gibraltar, a powerful bargaining chip — and a potential opportunity to renew calls for joint sovereignty over the territory, which is heavily reliant on access to the Spanish mainland. It also gave a few nationalist Britons cause to grumble and even threaten Madrid with war.

Some 30,000 British citizens live in the shadow of the Rock of Gibraltar, a limestone monolith that owes its name to the Moorish conqueror who made the narrow crossing from North Africa in 711. In last year's Brexit referendum, Gibraltarians voted almost unanimously to remain in the European Union, largely because they knew any departure from Europe's common market would wreak untold havoc upon their little community.

The irony is that, virtually from the beginning, Gibraltar was subject to heated European dispute and negotiation. In 1704, an expeditionary force led by the British captured the narrow strip of land by the Rock during the complicated War of the Spanish Succession. That conflict ended in 1713 with a series of peace treaties signed in the Dutch city of Utrecht. One of those documents gave Gibraltar to Britain (it was linked to a perhaps more important deal at the time — a contract that gave Britain an exclusive right to supply Spanish colonies with African slaves for the next three decades).

AD

AD

This treaty stated that Gibraltar's “town, castle and fortifications were to be held and enjoyed forever without any exception or impediment whatsoever.” Given the peninsula's location, it provided the British with a strategic point from which to control or interfere with sea traffic in the Mediterranean. Almost immediately, challenges to British control emerged. The Dutch, whose troops had taken part in the 1704 invasion, had their own claims subdued by British diplomats. Spain attempted to retake the territory at various points in the 18th century.

In 1727, a Spanish force laid siege to Gibraltar by land and sea and conducted a series of heavy bombardments. The British garrison withstood the attack, while the Spanish guns began to malfunction and explode. The British would reject various Spanish requests to give up the territory. In 1778, as Spain contemplated entering the American War of Independence along with the French, Madrid made yet another failed overture. The First Count of Floridablanca, the chief minister in the Spanish court, was said to have grumbled about “this pile of rocks called Gibraltar, which gives nothing except worries and expenses, troubles us and prevents our permanent friendship.”

Nevertheless, Gibraltar hosted what was perhaps the largest and most drawn out military engagement of the American War of Independence — no matter that it took place an ocean away. A combined French and Spanish force launched a prolonged assault on “this pile of rocks” from 1779 to 1783, the longest siege ever endured by British troops. Constant Spanish cannonade from land and sea laid waste to much of the town by the seaside, but failed to dislodge the British batteries up on the cliff. British troops used a network of tunnels to aim their guns from a steep angle directly at the ships below. (The tunnels proved a strategic asset as late as World War II.)

AD

AD

On Sept. 13, 1782, the French and Spanish had massed about 35,000 troops around Gibraltar. They unleashed a blistering bombardment from batteries both on land and floating close to the shore, launching about 40,000 artillery shells. About 80,000 Spaniards gathered in the surrounding hills to watch the awesome show.

The attack, known as the “Grand Assault,” failed. Gibraltar remained in British hands.

The 19th century saw the demise of Spain as an imperial power and the rise of Britain as a dominant global player. There was little question of Gibraltar's status as a key British naval base. But the dispute flared again under Spain's 20th-century fascist leader, Gen. Francisco Franco. Franco defied pressure from Nazi Germany to take the peninsula in 1940 and maintained his nation's technical neutrality, but he sealed Gibraltar's land borders in 1969.

AD

AD

“Families divided by the separation were forced to shout news of births and deaths across a fence, their words dying in the sea wind on particularly blustery days,” wrote my colleague Griff Witte.

The borders were only fully reopened in 1985, a full decade after Franco's death and a year before Spain joined what is now the European Union.

British Foreign Office documents from the 1980s revealed how Spanish King Juan Carlos I told British authorities at the time that it was “not in Spain's interest to recover Gibraltar in the near future.” Doing so would lead to immediate claims from Morocco for the return of Ceuta and Melilla, two small patches of North Africa that remain Spanish territory to this day.

Still, tensions have flared over numerous differences, including spats over fisheries and the presence of British nuclear submarines in Gibraltar's harbor. The territory, which has become a conspicuous offshore haven for gambling companies and hedge funds, remains steadfastly loyal to Britain. In referendums held in 1967 and 2002, nearly all voters opted to maintain ties to London.

AD

AD

But that devotion will be put to the test by Brexit. About 12,000 workers cross the border every day from neighboring Andalusia; Gibraltar imports almost everything.

Gibraltar's chief minister, Fabian Picardo, declared to Witte earlier this year that “the people of France are French, the people of Germany are German and the people of Gibraltar are British.” But he added that the vote to leave the European Union was a “deep sorrow” for Gibraltarians, hinting at the difficulties that lie ahead.