Nato states have signed an agreement with Macedonia, clearing the way for the Balkan nation to become the military alliance's 30th member.
Each Nato member will now need to ratify the accession protocol.
Last month the Greek parliament backed a deal ending a 27-year row over its northern neighbour's name.
They approved the name Republic of North Macedonia. Greece had blocked Macedonia's membership saying the name implied territorial ambitions.
The Greek region of Macedonia includes the country's second city Thessaloniki. Greek lawmakers approved the deal despite widespread opposition from the public.
Macedonia's Foreign Minister Nikola Dimitrov said the country would change its name "in a matter of days" following the signing of the accession protocol.
"This wasn't inevitable - this wasn't even very likely to happen," he said, praising the political leaders on both sides who proved "the impossible is actually doable".
"This is a family that strives to make our world more peaceful and a better place. This is a journey that has made us more mature... we have proven that we can assume our responsibility, face a problem, and resolve those problems," he said.
"In a matter of days, we'll resolve the last remaining dispute we have with any of our neighbours."
The prolonged dispute meant that until now Greece also frustrated Macedonia's drive to join the European Union.
What happens next?
Nato Secretary General Jens Stoltenberg said the signing was "a historic day".
It is not quite the final hurdle - but the long journey to becoming North Macedonia has definitely entered the home straight, BBC Balkans correspondent Guy De Launey reports.
Nato membership is the first significant prize for the Macedonian government, our correspondent adds.
Macedonia would have reached this point a decade ago - but Greece had blocked its membership.
Now Greece is set to become the first country to ratify the accession protocol. That is likely to happen this week, our correspondent adds.
Then Macedonia will inform the United Nations and other institutions about its new name.
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.
Many Greeks were enraged that their northern neighbour - a Slavic country - had adopted a Hellenic name that dates back to antiquity.
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.
What is in the deal?
The deal was signed last June by the two countries' prime ministers.
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.