Brussels - Amsterdam and Paris have won the right to host two major EU agencies when they leave London after Brexit, in a suspenseful vote that eventually had to be decided by the drawing of lots.
The European Medicines Agency will relocate to the Dutch city, while the French capital will be the new home of the European Banking Authority.
The two watchdogs, with a total of 1,000 highly skilled jobs between them, are currently based in London's Canary Wharf district but must leave before Britain quits the EU in March 2019.
But the fate of the some most prized spoils of Britain's decision to quit the EU had to be decided by a lucky dip after three tense rounds of voting for both agencies failed to produce a clear winner.
Amsterdam won out late Monday against the Italian city of Milan, while Paris beat the Irish capital Dublin.
"It was a big transparent bowl with two small lots, and it fell to me to draw the lot," said Matti Maasikas, the deputy EU affairs minister of Estonia, which holds the bloc's rotating presidency.
- 'Attractiveness of France' -
"The procedure was accepted by everyone and followed by the Estonian presidency to the letter."
French President Emmanuel Macron said the choice of Paris for the banking regulator showed the "attractiveness of France".
EU President Donald Tusk said on Twitter before the vote that "whatever the outcome, the real winner of today's vote is EU27. Organised and getting ready for Brexit."
Diplomats compared the complex voting process to the annual Eurovision Song Contest. The production's nail-biting televised voting sequence is one of the most watched TV moments in Europe and is known for its come-from-behind surprises.
The Netherlands hailed the decision to relocate the EMA to Amsterdam as "good news for all patients in Europe".
"It took a while to make the decision and the selection process was intensive, but it shows that the EU27 is able to make good decisions, also after Brexit," Dutch Foreign Minister Halbe Zijlstra said.
The battle for both agencies has been bitterly contested, with governments jostling to win the backing of other countries with "hot bargaining" behind the scenes, a diplomatic source told AFP.
But it has also been deeply political. Carles Puigdemont, the sacked leader of Catalonia, said that Barcelona had been the "favourite" but that the "state had condemned it", blaming violence over the region's disputed independence vote.
There were 16 candidates to be the new home of the EMA, one of the world's most powerful drugs watchdogs, which employs 900 pharmaceutical experts, biologists and doctors from every corner of Europe.
There was a smaller batch of eight bidders for the EBA, the banking regulator with 159 staff members. The agency is perhaps best known for its regular "stress tests" on the EU's financial sector in the wake of the global financial crisis.
Member states brought out all the stops to extol the merits of their candidate cities, producing glossy brochures and videos and offering a host of perks.
- 'Self-inflicted wound' -
"We also have a very stylish queen, and enjoy fish and chips," said a video for Amsterdam's bid, emphasising a continuity with two famed parts of British life.
The European Commission, the EU's executive arm, delivered an evaluation of the applications in September based on a range of criteria, from transport links to job prospects for spouses and schools.
But the staff of the agencies in question, already being forced to up sticks from London, had reportedly been nervous about some of the candidates, reportedly including Bratislava, Warsaw, Bucharest and Sofia.
For Britain the departure of the two agencies is an economic and political blow.
"For the UK, its loss is the first self-inflicted wound of Brexit," said the centre-right European People's Party, the largest group in the European Parliament.
By Danny Kemp