In Athens, Greek Prime Minister Alexis Tsipras called the deal "historic".
Greece's Alexis Tsipras and Macedonia's Zoran Zaev said the former Yugoslav republic's new name for both domestic and worldwide purposes would be Republic of North Macedonia.
The nationality of the country's citizens will be listed in official documents in English as "Macedonian/citizen of the Republic of North Macedonia", Greek officials said.
"Maybe what has the most historic gravity and value for Greece (is that) according to this accord. our northern neighbours don't have, and can not assert, any link to the ancient Greek culture of Macedonia", Tsipras said in a televised address on Tuesday evening.
Lake Prespa is split in three between Greece, the Republic of North Macedonia and Albania.
It was only with the adoption of a provisional name - the Former Yugoslav Republic of Macedonia (FYROM) - that the country was finally admitted into the United Nations in 1993.
Zaev said resolving the long-standing issue would open Macedonia's access to North Atlantic Treaty Organisation and the European Union.
"The chance is here and it must be seized, bravely, as this is the only patriotic way", Macedonian Prime Minisrter Zoran Zaev told a press conference in Skopje.
Opponents in Macedonia have called any adjustment of the country's name a form of treason and a cave-in to Greek demands.
The compromises to resolve the name issue have faced dissent in both countries, threatening to split Greece's governing coalition and provoke a rift between Macedonia's prime minister and president.
However, Mr Tsipras said, this will be contingent on Macedonia completing the constitutional changes.
Skopje also needs to revise its constitution, Tsipras said, before Greece ratifies the deal.
Mickoski charged that Prime Minister Zoran Zaev "capitulated" to Greece in making the deal. I believe in the democracy of the internet and want to keep this site and its enriching content free for everyone.
Macedonia's new name will be put up for a referendum, to be held in autumn.
The name issue has been blocking Skopje's aspirations to join North Atlantic Treaty Organisation and the European Union for years.
Officials in Albania are hailing the agreement between bordering Greece and Macedonia to end their decades-long name dispute as good for the whole Western Balkans region.
Greece has a northern province called Macedonia, also the cradle of ancient Macedonia and its most famous leader, Alexander the Great.
In a statement, the Party of European Socialists (PES) welcomed the agreement reached by the two Prime Ministers.
European Council President Donald Tusk tweeted his support for the agreement: 'Thanks to you the impossible is becoming possible'.