Greece and Macedonia on Sunday signed a historic preliminary agreement to rename the small Balkan nation the Republic of North Macedonia, ending a row that has poisoned relations between the two neighbours since 1991.
"This is a brave, historic and necessary step for our peoples," said Greek Prime Minister Alexis Tsipras.
"We are here to heal the wounds of time, to open a path for peace, fraternisation and growth for our countries, the Balkans and Europe," he said.
"Our two countries should step out of the past and look to the future," said Macedonian Prime Minister Zoran Zaev.
"By signing the agreement... we have really moved mountains."
But as the two countries' foreign ministers signed the deal Greek protesters clashed with riot police, who beat them back with tear gas near the small village of Pisoderi, 25 kilometres (16 miles) away.
Six policemen and six protesters were injured, police said, as around 500 demonstrators waving Greek flags tried to approach the ceremony.
The accord aims to start unravelling one of the world's longest diplomatic disputes, which began 27 years ago with Macedonia's declaration of independence but dates back centuries.
"The time has come again to sing happy songs in the Balkans," Tsipras said, moments before the document was signed by the foreign ministers.
Zaev and several of his ministers arrived by speedboat at the picturesque fishing village of Psarades under a sunny sky, on the southern bank of Lake Prespa, one of the natural boundaries between the two countries.
Tsipras and Zaev embraced on the village dock and were treated to a standing ovation by gathered dignitaries.
UN under-secretary-general for political affairs Rosemary DiCarlo, longterm UN negotiator Matthew Nimetz, EU diplomatic chief Federica Mogherini and EU enlargement commissioner Johannes Hahn were on hand, snapping pictures with their smartphones.
Nimetz, who turned 79 on Sunday, and was given a birthday cake, has been trying to broker a solution since 1994, first as a US envoy and subsequently on behalf of the UN.
But it was the election of Zaev in 2017, replacing nationalist prime minister Nikola Gruevski, that proved crucial.
An economist and former mayor of Strumica, Zaev made a rapprochement with Greece a priority to secure his country's membership of the European Union and NATO, blocked by Athens for years.
After the signature, Tsipras crossed over to the Macedonian side of Lake Prespa for lunch, becoming the first Greek prime minister to visit the neighbouring state.
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 -- a source of intense pride for modern-day Greeks.
The two premiers, born just months apart in 1974, have bucked strong hostile reactions at home to push ahead with the agreement.
- Accusations of treachery -
Tsipras has been accused of treachery by Greek hardliners, and on Saturday defeated a vote of censure against his government amid protests and clashes with police outside parliament.
In Macedonia, President Gjorge Ivanov plans to exercise a one-time veto option to block the deal that the nationalist opposition has called a "capitulation".
The Macedonian parliament is scheduled to start debating the agreement the coming week.
The accord still needs to be approved by Macedonia's parliament and then pass a referendum. The constitution must also be revised by the end of the year, before Greece's parliament is called to ratify it.
On Sunday, some 5,000 people marched peacefully against the name deal in Bitola, in southwestern Macedonia, an event organised by the main opposition VMRO-DPMNE party.
But in Skopje special police fired tear gas after some among 2,000 people protesting in front of the parliament hurled stones and flares and attempted to break through a police cordon.
The protestors, who organised themselves through social networks, chanted "Zaev traitor".
The state-run MIA news agency reported that 10 people including seven police officers were injured.
- 'Brave steps' -
Tsipras' domestic critics say he has bargained away Greece's diplomatic advantages -- the power of veto over EU and NATO accession -- for a deal that could backfire.
Specifically, by officially recognising a Macedonian language and nationality, it is almost certain that the country will be called Macedonia by the broader world, instead of North Macedonia, opponents of the deal argue.
Officials in Athens insist the deal will help stabilise the historically volatile Balkan region, permitting Greece to focus on other regional challenges, Turkey among them.
Macedonia was admitted to the UN in 1993 under the provisional name of the "Former Yugoslav Republic of Macedonia", but more than 120 countries including Russia and the United States have recognised the Balkan country under the name of "Republic of Macedonia".
"It is indeed a historic day... I believe this will be inspiration for many in the region and Europe to make brave steps," Mogherini said.
Skopje hopes to secure a date to begin EU accession talks at an EU summit in late June and an invitation to join NATO in mid-July.