He added that Macedonia would take a new "compound name with a geographical denominator", without spelling out the name.
"We have a deal, I'm happy because we have a good deal which covers all the preconditions set by the Greek side", he said.
"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", said NATO Secretary General Jens Stoltenberg in a statement.
Greece has long objected to its northern neighbour being called Macedonia because it has its own northern province of the same name.
Macedonia hopes that resolving the name dispute will help clear the way for it to join the European Union and North Atlantic Treaty Organisation.
The deal was welcomed by EU officials, with European Council president Donald Tusk tweeting his "sincere congratulations" to Mr Tsipras and Mr Zaev.
"Macedonia will be called the Republic of Northern Macedonia [Severna Makedonija]", Zoran Zaev, the country's prime minister, announced Tuesday.
He added that Macedonia "cannot and will not be able in the future to claim any connection with the ancient Greek civilisation of Macedonia".
Today (June 12), leaders from both nations said a final agreement may well have been reached.
Greece will then back invitations for Macedonia to join North Atlantic Treaty Organisation and start negotiations on joining the European Union.
Greek Prime Minister Alexis Tsipras.More news: Kim summit pleases China, while Japan puts on brave face
Last week in Pella, Greece, protesters opposed the use of the name "Macedonia" in any solution to the dispute between Athens and Skopje. Macedonia will also have to change its constitution, according to Zaev.
Bulgaria, which also shares a border with Greece and Macedonia, said the new name should not be used for territorial or claims concerning language, culture, history or identity.
"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 new name will need to be approved by the Macedonian people and the Greek parliament, but by the sounds of things it's a goer. "Thanks to you, the impossible is becoming possible", he said.
"I am keeping my fingers crossed", he said.
Both governments have faced criticism ahead of the compromise and on Tuesday Macedonia's President Gjorge Ivanov signalled his concern.
Greek Foreign Minister Nikos Kotzias had prepared a 20-page draft agreement after repeated talks with his Macedonian counterpart Nikola Dimitrov.
A bronze statue of Alexander the Great can be seen in the northern port city of Thessaloniki, Greece.
European Union foreign affairs chief Federica Mogherini and Johannes Hahn, commissioner for European Union enlargement, said they looked forward to accession negotiations beginning with Skopje in June.
"We don't agree and we won't vote for any deal including the name 'Macedonia, '" Panos Kammenos, Greek Defense Minister and head of the rightist Independent Greeks party, said.