ATHENS, Greece -- A U.N. envoy has praised Macedonia after its parliament approved a deal with Greece that would rename the country North Macedonia.

Matthew Nimetz said in a statement that the agreement, which remains to be ratified by Greece, paves the way for "a firmer basis for peace and security in the Balkans."

"I wish to congratulate the parliament and the country's citizens for this accomplishment and for the democratic manner, in which this important process was undertaken," he said.

The agreement on changing the name comes after a 27-year dispute, with Greece complaining that the name Macedonia implies claims on Greece's own territory and cultural heritage.

The passage has been hailed by European leaders, who want to see the dispute resolved and Macedonia admitted, under its new name, to NATO. Greece has blocked Macedonia's NATO entry, as well as talks toward EU membership.

Nimetz has been the U.N. secretary-general's personal envoy on the naming dispute since 1999 and was also President Bill Clinton's special envoy as mediator on the issue from March 1994 to September 1995. In the latter capacity, he brokered a so-called interim deal whereby Greece dropped its embargo on Macedonia in exchange for the latter's modifying its flag, which included a symbol found in the grave of Philip II, ruler of the ancient Greek kingdom of Macedonia and father of Alexander the Great.

Macedonia approved the deal Friday, while Greece's parliament is expected to vote on it before March. The vote is expected to be a cliffhanger, with Prime Minister Alexis Tsipras' coalition partner, Panos Kammenos, the defence minister and leader of right-wing populist Independent Greeks, virulently opposed.

However, it appears that some of Kammenos' own lawmakers are ready to desert him, while some lawmakers from small centre-left parties are ready to back the deal. Tsipras himself has repeatedly expressed his confidence that he will find the needed 151 votes to pass the deal with a simple majority in Greece's 300-member Parliament.