After years of disputes, Athens and Skopje have agreed the Former Yugoslav Republic of Macedonia will be renamed the "Republic of North Macedonia".
Prime Minister of the Former Yugoslav Republic of Macedonia Zoran Zaev hailed a "historic solution" on Tuesday after Skopje and Athens resolved a longstanding row by agreeing to rename his country the Republic of North Macedonia.
The 27-year dispute has led to frequent disagreement and protests, but the two countries agreed on the new title of the former Yugoslav republic after months of intensive diplomacy.
"There is an agreement. We have a historic solution after two and a half decades. Our agreement includes Republic of North Macedonia for overall use," Zaev told reporters in the capital Skopje.
Greece has long objected to its northern neighbour being called Macedonia because it has its own northern province of the same name.
Greek Prime Minister Alexis Tsipras also declared a deal had been struck.
"We have reached an accord, a good accord that covers all the conditions set by Greece," Tsipras said in televised comments after briefing Greece's president Prokopis Pavlopoulos on the accord.
Macedonia hopes that resolving the name dispute will help clear the way for it to join the European Union and NATO.
European Council President Donald Tusk tweeted his support for the agreement: "Thanks to you the impossible is becoming possible."
"I am keeping my fingers crossed," he said.
The deal still needs to be approved by the Macedonian and Greek parliaments.
Greek officials earlier said the list of potential names included "New Macedonia" and "Upper Macedonia", but after months of discussions "North Macedonia" was chosen.
Greek Foreign Minister Nikos Kotzias had prepared a 20-page draft agreement after repeated talks with his Macedonian counterpart Nikola Dimitrov.
Kotzias told Kontra TV on Monday that the agreement would specify that Macedonia's language is of Slavic origin.
"It's clear that (Macedonia) bears no relation to the ancient (Macedonian) culture... and that their language belongs to the Slavic language," he said.
Both governments have faced criticism ahead of the compromise and on Tuesday Macedonia's President Gjorge Ivanov signalled his concern.
"There is a need for a wider national consensus to find a solution that won't hurt the dignity of the Macedonian people and citizens," said Ivanov.
He is close to a nationalist party which was defeated by Zaev in elections last year.
This year there have been several protests against an agreement in Skopje, as well as in Athens and Greece's second city of Thessaloniki in the north.
Greek Defence Minister Panos Kammenos, a hardline junior coalition partner in Tsipras's government, earlier dismissed talk of a deal, saying there was "no chance" Zaev could get it approved.
Greece's parliament will be called to ratify the agreement after Macedonian lawmakers approve it, provided that Skopje fulfils preliminary EU and NATO requirements to begin membership talks, Kotzias said.
Skopje hopes to secure a date to begin accession talks at an EU summit in late June, and an invitation to join NATO in mid-July.
"This historic agreement is testament to many years of patient diplomacy, and to the willingness of these two leaders to solve a dispute which has affected the region for too long," NATO Secretary General Jens Stoltenberg said in a statement.
"This will set Skopje on its path to NATO membership. And it will help to consolidate peace and stability across the wider Western Balkans," he added.
The EU's diplomatic chief Federica Mogherini said the deal "contributes to the transformation of the entire region of southeast Europe".
Athens has long objected to its neighbour's constitutional name - the Republic of Macedonia - because it fears it could imply territorial ambitions.
Ancient Macedonia was the cradle of Alexander the Great's empire, a point of pride to Greeks today.