PRESPES, Greece — The foreign ministers of Greece and Macedonia signed an accord on Sunday to rename the former Yugoslav republic the "Republic of North Macedonia."

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 E.U. 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 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 percent of Greeks object to the compromise, an opinion poll by the Proto Thema newspaper showed on Saturday.

Greece had 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 civilization.

The subject is a deeply emotional one for many Greeks. On Saturday, protesters outside the parliament building shouted "traitor, traitor!" as lawmakers debated inside.

"I'm just furious," said Theologos Ambotis, 69, a monk. "Conceding on the name is conceding on territory. Macedonia and Alexander the Great is Greek history and culture, and they are just giving it away to Skopje."

Under the terms of the accord, the country will be known as "Republic of North Macedonia" and Greece will lift its objections to the renamed nation joining the European Union and the NATO military alliance.

Protests were scheduled on both sides of the border on Sunday.

Veteran United Nations mediator Matthew Nimetz, who has been overseeing talks for a quarter century, described the agreement as an honorable deal. It was, he said, an example of "how neighbors can solve a problem if they really work at it".

"Today is my birthday," said Nimetz, who turned 79 on Sunday. "I told my family this year I don’t need any gifts because two prime ministers are going to give me a big gift."