Greece was wrong to block Macedonia's bid to join Nato in 2008 because of a row over its name, the International Court of Justice has ruled.
It said Athens should have abided by a 1995 deal not to block Macedonian applications if made under the name Former Yugoslav Republic of Macedonia.
The ICJ ruling does not address the neighbours' dispute over the name.
The dispute has been rumbling on since Macedonia gained independence from Yugoslavia in 1991.
It is a deeply sensitive issue in both countries, BBC's Balkans correspondent Mark Lowen explains.
Greece says the use of the name by its neighbour implies territorial aspirations to its northern province of the same name.
The majority of Greeks also feel strongly that the term Macedonia is of Hellenic origin, while Macedonians argue it is an integral part of their Slavic identity and they will not accept to change it, our correspondent says.
"Greece, by objecting to the admission of the former Yugoslav Republic of Macedonia to Nato, has breached its obligation," the ICJ said.
The ruling makes it politically more difficult for Greece to object to any future application by Macedonia to either Nato or the EU.
This is a significant diplomatic victory for the tiny former Yugoslav republic against its larger neighbour and will prompt celebration on the streets of Skopje, our correspondent says.
Soon after Yugoslavia's southernmost republic declared itself independent under the name Republic of Macedonia in 1991, Greece imposed a trade embargo.
The embargo was lifted when Macedonia agreed in 1995 to change its flag and constitution and apply to join international institutions under the name Former Yugoslav Republic of Macedonia, while negotiations continued over the name.
But much to Greece's anger, the country has retained its constitutional name Republic of Macedonia.
Greece's foreign ministry said on Monday it was "reviewing" the ICJ decision.
"Greece will continue to pursue negotiations in good faith to reach a mutually acceptable solution on the name of the former Yugoslav Republic of Macedonia, within the spirit and letter of the relevant resolutions of the Security Council and the General Assembly of the United Nations," it said.
Macedonian foreign minister Nikola Poposki welcomed the ICJ decision, stressing that Macedonia remained "strongly committed to finding a lasting, mutually acceptable solution to the difference with Greece over the name".