The foreign ministers of Greece and Macedonia have signed an accord to rename the former Yugoslav republic as the "Republic of North Macedonia."
Greek foreign ministers Nikos Kotzias and Nikola Dimitrov of Macedonia signed the document in Psarades, on the shore of Lake Prespa.
The landmark accord follows decades of inconclusive talks which had soured relations between the two countries and held up the admission of the Balkan state into the European Union and NATO, of which Greece is a member.
The agreement still requires the approval of both parliaments and a referendum in Macedonia.
"We have a historic responsibility that this deal is not held in abeyance, and I am confident that we will manage it," Greek Prime Minister Alexis Tsipras said on Sunday, as he and his Macedonian counterpart Zoran Zaev received a standing ovation from guests at a lakeside ceremony.
Tsipras survived a no-confidence vote mounted by Greece's opposition in parliament on Saturday, but the depth of public emotion against the deal is strong.
Up to 70 per cent of Greeks object to the compromise, an opinion poll by the Proto Thema newspaper showed.
Under the deal, Greece will lift its objections to the renamed nation joining the EU and NATO.
"Our two countries have to turn from the past and look to the future," Zaev said.
"We were bold enough to take a step forward."
Greece has been in dispute with Macedonia since 1991 over the former Yugoslav republic's name, arguing it could imply territorial claims over the Greek province of Macedonia and an appropriation of ancient Greek culture and civilisation.
The subject is an emotional one for many Greeks. On Saturday, thousands of protesters outside the parliament building shouted "Traitor, traitor!" as lawmakers debated inside.
Australian Associated Press