"We have a deal, I'm happy because we have a good deal which covers all the preconditions set by the Greek side", said Greek Prime Minister Alexis Tsipras.
In a nutshell, Greek people felt like the name belonged to them because it ties in with the country's heritage and the Macedon Kingdom - the king of which was Alexander the Great, who you'll have heard of.
Greece argued that by calling itself Republic of Macedonia the neighboring country was stating a territorial claim of the Greek northern province, also called Macedonia.
Ancient Macedonia was the cradle of Alexander the Great's empire, a point of pride to Greeks today.
The name issue has been blocking Skopje's aspirations to join North Atlantic Treaty Organisation and the European Union for years. Our agreement includes Republic of North Macedonia for overall use, ' Zaev told reporters in the capital Skopje.
Today the 27-year impasse ended as two nations finally came to a resolution: The former Yugoslav republic is getting a new name, the Republic of North Macedonia.
After splitting from the former Yugoslavia, Macedonia was admitted into the United Nations in 1993 as the former Yugoslav Republic of Macedonia (FYROM).
The proposed name change has been resisted by sections of the Macedonian public. There were also rallies in Macedonia in spring, demanding the country's name to be left in place.
Apparently other names thrown into the pot included Gorna Makedonija (Upper Macedonia), Nova Makedonija (New Macedonia) and Ilinden Macedonia.
Macedonia became a candidate for membership of the European Union in 2005 but Greece blocked the start of negotiations.
European Council President Donald Tusk tweeted his "sincere congratulations" to Tsipras and Zaev.
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.
In a statement, Nimetz congratulated the two prime ministers on reaching an agreement: "I have no doubt this agreement will lead to a period of enhanced relations between the two neighbouring countries and especially between their people".
Greece is to ratify the deal in parliament after Macedonia has made the necessary changes to its constitution, Tsipras said.
The deal still needs to be approved by the Macedonian and Greek parliaments.
The tiny Balkan country has repeatedly tried to join the European Union and North Atlantic Treaty Organisation, but its attempts have been blocked by neighbouring Greece.
"In essence, the (deal) is acceptance of all Greek positions", VMRO-DPMNE leader Hristijan Mickoski said.