Greece’s parliament has voted narrowly to back a historic agreement ending a 27-year dispute over its northern neighbour’s name.
Parliament in Athens agreed by 153 votes to 146 to approve the name Republic of North Macedonia, despite widespread opposition from the public.
“North Macedonia was born today,” said Greek Prime Minister Alexis Tsipras.
Greece has rejected Macedonia’s name since its independence in 1991, as there is a Greek region of that name.
Failure to find an appropriate name meant that Greece frustrated Macedonia’s drive to join both Nato and the European Union.
Opposition to the deal is strongest in the northern Greek region of Macedonia, and polls suggest more than 60% of Greeks dislike it.
Thousands of people protested outside parliament on Thursday night, but far smaller numbers braved the torrential rain on Friday as the vote took place.
How leaders reacted
Mr Tsipras, who was involved in negotiating the deal, said it was a “historic day”.
“Congratulations my friend,” his Macedonian counterpart Zoran Zaev responded on Twitter. “Together with our peoples we reached a historic victory.”
There were warm words from EU officials, who praised both countries for setting “an example of reconciliation for Europe” by resolving “one of the most entrenched disputes in the region”.
The debate in the chamber lasted more than 38 hours, and more than 200 MPs spoke.
The centre-right opposition condemned the deal as a “national defeat” and members of the far-right Golden Dawn party shouted “traitors!” as the vote came to an end.
Why is the deal so divisive?
The row has run deep in both countries since Macedonia became a new nation after the collapse of Yugoslavia in 1991.
The Macedonia region in Greece includes its second city Thessaloniki. Many Greeks were enraged their northern neighbour had adopted a name that dates back to antiquity – fearing their neighbours had territorial ambitions.
The Greek region, which includes the birthplace of Alexander the Great, is considered an intrinsic part of Greek heritage.
At the UN, its neighbour became known simply as Fyrom, an acronym for the Former Yugoslav Republic of Macedonia, and attempts to resolve the matter foundered for decades.
Fury inside and out
Analysis by Mark Lowen, BBC News, Athens
The angry scenes in parliament echoed the fury outside: as one MP spoke of the death threats she’d received in supporting the Macedonia bill, and another shouted “no to treason” while he voted, protesters on the steps of parliament screamed “traitors!”
In the past week, police have fired tear gas here as tens of thousands have demonstrated under the Greek flag, deploring what they saw as their government’s capitulation to pressure from Nato and the EU.
While outsiders might scratch their heads at the apparent absurdity of this row, Greeks are fiercely attached to their history.
“We’ve lost everything in the financial crisis – now we’re losing our dignity” is a familiar refrain from those protesting.
The right-wing opposition leader, ahead in the polls, says he’ll still veto North Macedonia’s EU accession when it comes to it – though by the time the small Balkan country is ready to join, passions may have calmed and Greeks will no doubt have other nationalist fish to fry.
Mr Tsipras lost his coalition government partner last week and had to survive a no-confidence vote in the run-up to the vote.
He had to rely on eight independent and opposition lawmakers to help him get the deal through parliament on Friday.
What is in the deal?
The deal was signed last June by the two countries’ prime ministers at Lake Prespa, which has shores in Greece, Macedonia and Albania.
It means that Macedonia will now become the Republic of North Macedonia, or North Macedonia for short.
Macedonia has already ratified the agreement and will inform the United Nations that the accord has been reached.
Aside from the name change, the deal carries assurances that there will be no attempt to appropriate the other country’s territory.
Within a month, a commission will be set up to look at the two countries’ history books, to ensure there is an objective interpretation of the past.
When does the new name take effect?
The Greek prime minister said on Friday that North Macedonia had been born, however it will still take time for the name to be formally declared.
Macedonian officials told the BBC that it would only be used when Greece ratified the Nato accession deal, expected within a few weeks.
That will take place after Nato ambassadors sign the accession protocol in the coming days.
But North Macedonia is likely to become formalised before that, when the government in Skopje tells the UN that both countries have agreed the deal.