SKOPJE (Reuters) - The Macedonian parliament formally ratified a landmark name agreement with Greece on Wednesday, paving the way for Skopje’s admission to NATO and the opening of accession talks with the European Union.

FILE PHOTO: Supporters of opposition party VMRO-DPMNE wave Macedonian flags as they take part in a protest over compromise solution in Macedonia's dispute with Greece over the country's name in Skopje, Macedonia, June 2, 2018. Picture taken June 2, 2018. REUTERS/Marko Djurica/File Photo

Last week the foreign ministers of the two countries signed an accord to rename the tiny ex-Yugoslav republic the “Republic of North Macedonia”, despite nationalist protests on both sides of their shared border.

Declaring its independence in 1991, Macedonia avoided the wars that battered some other ex-Yugoslav republics, but Greece refused to accept the country’s name, saying it implied territorial claims on the Greek province of Macedonia and amounted to an appropriation of its ancient civilization.

Greece blocked Macedonia’s efforts to join the EU and NATO.

In a vote boycotted by 51 opposition deputies, the ruling coalition in Macedonia’s 120-seat parliament, led by the Social Democrats of Prime Minister Zoran Zaev, approved the agreement.

Zaev, who with Greek Prime Minister Alexis Tsipras oversaw the signing of the deal on Sunday, told parliament that the accord brought Macedonia long-sought international recognition.

“With this solution, we have not only gained another friend and strategic partner ... we have (also) opened the gates to NATO and the EU,” Zaev said

Foreign Minister Nikola Dimitrov, who signed the agreement, said the deal protected the identity of the Macedonian nation.

Nationalists in both Greece and Macedonia remain opposed to the deal, which must also be approved by the Greek parliament. Macedonia has to amend its constitution to conform with the provisions of the deal. A referendum is also expected in Macedonia in the autumn.

Macedonian President Gjorge Ivanov also opposes the accord. Under the constitution Ivanov can return it to parliament for reconsideration but not veto it indefinitely.