Macedonia's parliament has approved a constitutional amendment to change the country's name to the Republic of North Macedonia.
Prime Minister Zoran Zaev narrowly secured the two-thirds majority needed in the historic vote amid a boycott by opposition nationalists.
Protesters outside parliament denounced what they called an act of treason.
The name change is aimed at ending a 27-year dispute with Greece, which has its own region called Macedonia.
The Greek parliament must now give its approval under a deal signed by Greek Prime Minister Alexis Tsipras and Mr Zaev in June.
That will lift Athens' veto on Macedonia's bids to join Nato and the European Union.
What has the reaction been?
"A new historical chapter in our statehood has been written this evening," the Macedonian government said in a statement.
"It makes absolutely plausible two of our biggest state interests - membership in Nato and EU."
Eighty-one deputies voted in favour of the change in the 120-seat chamber.
Nato Secretary General Jens Stoltenberg hailed the vote, saying the alliance "strongly supports the full implementation of the agreement, which is an important contribution to a stable and prosperous region."
Johannes Hahn, the EU commissioner in charge of enlargement, said: "(I) hope that this historic decision creates a positive dynamic for reconciliation in the whole Western Balkan region."
Mr Tsipras called Mr Zaev to congratulate him on the "successful conclusion of the process to revise the constitution of the former Yugoslav Republic of Macedonia," his office said.
More than 90% of Macedonian voters backed the name change in a non-binding referendum in September but the vote was rendered invalid due to low turnout.
What's the source of the dispute?
When Macedonia declared independence during the break-up of Yugoslavia in 1991, Greece objected to its new neighbour's name.
Present-day Macedonia and northern Greece were part of a Roman province called Macedonia. And both claim the heritage of Alexander the Great two millennia earlier.
Greece's objections forced the UN to refer to the new country as "the former Yugoslav Republic of Macedonia".
Athens also vetoed Macedonia's attempt to join Nato in 2008 - and blocked its EU membership ambitions.
Since 1991, many suggestions have been proposed, then rejected.
But a change of government in Macedonia in 2017 finally brought the start of serious negotiations, which led to the deal reached last year.
What happens next?
Under the agreement, the country's language will be called Macedonian and its people known as Macedonians (citizens of the Republic of North Macedonia).
The new name will be used both internationally and bilaterally, so that even the 140 or more countries that recognise the name Macedonia will also have to adopt North Macedonia. In Macedonian, the name is Severna Makedonija.