People wave Macedonian flags during a protest in front of the Government building in Skopje on June 2, 2018.

Greece and Macedonia have reached an historic accord to resolve a dispute over the former Yugoslav republic's name that has troubled relations between the two neighbors for decades.

Under the deal, Macedonian Prime Minister Zoran Zaev said his country would officially be called the "Republic of Northern Macedonia". It is currently known formally at the United Nations under the interim name "Former Yugoslav Republic of Macedonia".

Zaev said the deal would open the way for the tiny Balkan nation's eventual membership of the European Union and NATO, currently blocked by Greece's objections to its use of the name Macedonia. Athens say that name implies territorial claims on a northern Greek province of the same name.

"There is no way back," Zaev told a news conference after speaking with his Greek counterpart Alexis Tsipras by telephone. A meeting of the two soon may seal the deal, he said.

"Our bid in the compromise is a defined and precise name, the name that is honourable and geographically precise - Republic of Northern Macedonia."

"By solving the name question, we are becoming a member of NATO," Zaev added.

The accord still requires ratification by the two national parliaments and a referendum in Macedonia, a tough test for the leaders in both countries.

"Today is a hard day for the Republic of Macedonia. We just saw a press conference where the defeat is shown as a fake victory," Hristijan Mickoski, president of opposition party VMRO-DPMNE said.

Skopje also needs to revise its constitution, Tsipras said, before Greece ratifies the deal.

The name dispute has soured relations between the two neighbors at least since 1991, when Macedonia broke away from former Yugoslavia, declaring its independence under the name Republic of Macedonia.