Greece and Macedonia have signed a deal that aims to settle a decades-long dispute over Macedonia's name.
Under the agreement, Greece's neighbour will be known as North Macedonia.
Greek PM Alexis Tsipras said it was "a brave, historic and necessary step for our peoples".
Heated rows over Macedonia's name have been going on since the break-up of the former Yugoslavia, of which it was a part, and have held up Macedonia's entry to Nato and the EU.
Greece has long argued that by using the name Macedonia, its neighbour was implying it had a claim on the northern Greek province also called Macedonia.
The two countries' leaders announced the deal on Tuesday and have pressed ahead despite protests.
Tsipras and his Macedonian counterpart Zoran Zaev watched as their foreign ministers signed the deal on Lake Prespa on Greece's northern border on Sunday.
The agreement still needs to be approved by both parliaments and by a referendum in Macedonia.
Nationalists on both sides say it erodes their identity.
On Saturday Tsipras survived a no-confidence vote over the deal amid accusations he made too many concessions.
It looked like the setting for a wedding. A white marquee erected on the banks of a picturesque lake. And indeed, one of the participants was agreeing to change its name.
After almost three decades of dispute, the northern neighbour of Greece should soon become North Macedonia.
An elderly man in the audience nodded and smiled. This was Matthew Nimetz - the UN mediator who has spent a quarter of a century trying to find a solution acceptable to both countries.
He called the prime and foreign ministers "four outstanding leaders" with "political courage, vision and diplomatic skills".
What would the agreement mean?
Under the deal, the country known at the UN as Former Yugoslav Republic of Macedonia (Fyrom) would be named Severna Makedonija, or Republic of North Macedonia.
Its language would be Macedonian and its people known as Macedonians (citizens of the Republic of North Macedonia).
As part of the agreement, Greece would lift its objections to the renamed nation joining the EU and Nato.
What happens now?
There is still some way to go before the name change becomes official.
Macedonia's parliament first needs to back the deal. That would be followed by a referendum in September or October.
If voters there support it, the government would have to change the constitution, which is a key Greek demand.
Things have been complicated further as Macedonia's President Gjorge Ivanov is refusing to sign the agreement.
He has the power to veto the deal - but not indefinitely.
If he refuses to sign it, it will be sent back to parliament for a second vote. If it passes again, President Ivanov would then be obliged to approve the legislation.
The deal will finally have to be ratified by the Greek parliament, a process which may also not be straightforward.