Greece and Macedonia have defied protests and set aside decades of dispute as they agreed on a new name for the Balkan state, potentially paving the way for Skopje's admission to the EU and NATO.
The foreign ministers of Greece and Macedonia signed an accord to rename the former Yugoslav republic the "Republic of North Macedonia," despite protestS over a deal seen as a national sellout by some on both sides.
In Prespes, a lake region which borders Greece, Macedonia and Albania, officials from the two countries embraced, shook hands and penned a deal in the presence of European and United Nations officials.
The agreement still requires the approval of both parliaments and a referendum in Macedonia.
That approval is far from assured, as it faces stiff opposition from the Greek public, and Macedonia's president has vowed to block the deal.
"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 the lakeside ceremony.
Mr Tsipras survived a no-confidence vote mounted by Greece's opposition in parliament yesterday, but the depth of public emotion against the deal is strong.
Up to 70% of Greeks object to the compromise, an opinion poll by the Proto Thema newspaper showed on Saturday.
In Psarades, the tiny lakeside community where the deal was signed, the village church bell tolled in mourning, draped in a Greek flag.
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," Mr 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.
Greek protesters clashed with riot police, who beat them back with tear gas, after they tried to approach the signature ceremony.
The protesters were surrounded by police near the small village of Pisoderi, a few kilometres away from the ceremony.
One detachment of riot police blocked the rural road leading to the lake, while others on mountain slopes threw stun grenades and tear gas at the crowd.
The authorities said some 500 people took part in the protest.
Since 1991, Athens has objected to its neighbour being called Macedonia because it has its own northern province of the same name, which in ancient times was the cradle of Alexander the Great's empire.