The name dispute has poisoned relations between the two countries since Macedonia's independence from Yugoslavia in 1991 and has prevented Macedonia from joining global institutions such as North Atlantic Treaty Organisation and the European Union.
Macedonia Prime Minister Zoran Zaev hailed a "historic solution" today after Skopje and Athens resolved a longstanding row by agreeing to rename his country the Republic of North Macedonia.
Greece has argued since Macedonia's independence from Yugoslavia in 1991 that the young country's name implied a claim to the territory and ancient heritage of Greece's northern region of Macedonia - the birthplace of ancient warrior king Alexander the Great.
It is now known formally at the United Nations under the interim name "Former Yugoslav Republic of Macedonia".
Macedonian Prime Minister Zoran Zaev addresses the media at the government offices in Skopje, Macedonia on June 12, 2018.
The new name - which in Macedonian is Severna Makedonija - will be used both domestically and internationally, while Macedonia will also amend its constitution as part of the deal.
In a statement, the Party of European Socialists (PES) welcomed the agreement reached by the two Prime Ministers.
NATO Secretary General Jens Stoltenberg said Tuesday's "historic agreement" was "testament to many years of patient diplomacy", and called on the two countries' prime ministers to finalize the deal.
"We must now make good use of the window of opportunity that has been pushed wide open to accompany and consolidate the winds of peace and cooperation in the entire region".
Zaev said he will put the deal to a vote in a referendum, while the Greek parliament will consider ratification before the end of the year.
European Union foreign affairs chief Federica Mogherini and commissioner Johannes Hahn issued a joint statement congratulating the two prime ministers "in reaching this historic agreement between their countries, which contributes to the transformation of the entire region of South-East Europe".
European Council President Donald Tusk tweeted his support for the agreement: 'Thanks to you the impossible is becoming possible'.
Greece has a northern province called Macedonia, also the cradle of ancient Macedonia and its most famous leader, Alexander the Great.
He added that Macedonia would take a new "compound name with a geographical denominator", without spelling out the name.
The deal would also require Macedonia revising its constitution.
The main opposition party in Macedonia, the conservative VMRO-DPMNE, accused Mr Zaev of "capitulating" to Greece.
It will stress that the Macedonian language belongs to the South Slavic group of languages, Tsipras said.
"I am keeping my fingers crossed", he said.
Tsipras said in a televised statement that Macedonia's name change would allow a clear distinction between Greece's province of Macedonia and the neighbouring country.