Following the latest round of discussions, Macedonia is now set to be known as the Republic of Northern Macedonia.
Skopje and Athens announced they can resolve their long and bitter dispute by agreeing on the composite name "Republic of North Macedonia" for Macedonia - a deal expected to unlock Skopje's European Union and NATO bids.
The neighboring nations Greece and Macedonia have been debating Macedonia's chosen name since 1991, when the small country that was once part of the former Yugoslavia adopted the name.
While the debate over the name might seem trivial, Greece has gone as far as to block Macedonia from joining North Atlantic Treaty Organisation or the European Union because of its name.
Greece's Alexis Tsipras and Macedonia's Zoran Zaev made the announcements shortly after speaking by phone.
A man holds a Greek flag next to a statue of Alexander the Great.
"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.
Greece had long demanded that Macedonia change or modify its name to avoid any claim to the territory and ancient heritage of Greece's northern region of Macedonia - birthplace of ancient warrior king Alexander the Great.
The name would be the Republic of North Macedonia, subject to approval.
Prime Minister Alexis Tsipras said Tuesday that a deal had been reached to give Macedonia a different name, addressing all of Greece's concerns.
Neymar goal caps impressive Brazil win over feisty Austria
He also seemed to revel in no longer having to carry the team on his shoulders. "His technical and creative ability is impressive. But fears of a right-back crisis seem to have been subdued after Danilo's solid performances against Croatia and Austria .
However, Mr Tsipras said, this will be contingent on Macedonia completing the constitutional changes.
Its new name will be the Republic of Northern Macedonia, which will be used both domestically and internationally.
"In other words, if the constitutional amendment is not successfully completed, then the invitation to join North Atlantic Treaty Organisation will be automatically rescinded and the accession talks with the European Union will not start", he said.
The deal still needs to be approved by the Macedonian and Greek parliaments. "I am keeping my fingers crossed". Tusk said: "Thanks to you the impossible is becoming possible", he said.
Greek Foreign Minister Nikos Kotzias had prepared a 20-page draft agreement after repeated talks with his Macedonian counterpart Nikola Dimitrov.
The two prime ministers are expected to sign the agreement over the next weekend.
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 southeast Europe".
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.
But Greek Defense Minister Panos Kammenos, whose right-wing Independent Greeks party is Tsipras' junior coalition partner, said he would reject the name agreement in a parliamentary vote.