Macedonian Prime Minister Zoran Zaev (C) waves to journalists after Macedonia's deputies voted to change the country's name to 'the Republic of North Macedonia' at the parliament in Skopje on January 11, 2019 | Robert Atanasovski/AFP via Getty Images Macedonia’s parliament backs name change Parliament backs change to North Macedonia.

SKOPJE, Macedonia — Macedonia will change its name to North Macedonia in an effort to end a decades-long dispute with Greece and unblock the path to NATO and the EU.

Eighty-one MPs approved historic amendments to Macedonia’s constitution on Friday evening after three days of high drama in Skopje's parliament.

Outside, small groups of protesters gathered in the snow, some wrapped in flags bearing the Vergina Sun, a symbol of Macedonian nationalism, and carrying placards reading “Stop genocide, Macedonia forever.”

Greece had demanded the name change in exchange for dropping its opposition to Macedonia joining both NATO and, potentially, the EU. Greek lawmakers have complained since the early 1990s that the name is part of a pattern of territorial and cultural infringement by Macedonia on the Greek region of the same name.

Prime Minister Zoran Zaev needed the backing of a two-thirds majority, or 80 of the parliament’s 120 MPs, to ratify the agreement he reached in June with Greek PM Alexis Tsipras — before a deadline of January 15. Opposition party VMRO-DPMNE opposed the name change, claiming it threatens Macedonian identity, and boycotted the vote.

The deal appeared on the brink on Thursday as Zaev and his Social Democrats (SDSM) sought the votes of four MPs from the tiny Besa party, which represents the country’s ethnic Albanian minority. Besa’s leader, Bilal Kasami, objected to the wording of one of the constitutional amendments, claiming it fails to reflect Macedonia’s multiethnic makeup.

Zaev faced a dilemma. If he changed the wording, he would lose the support of an independent parliamentary group of eight former VMRO-DPMNE defectors who had endorsed the name change. “The clock is ticking,” he told reporters at the time.

Pressure intensified on Friday, when European Commission President Jean-Claude Juncker told a press conference in Bucharest that he hopes both countries would “do what history is asking them to do.” Parliamentary sessions in Skopje were scheduled then cancelled in the afternoon while SDSM and Besa held emergency talks. By 5 p.m., the two parties released a joint statement announcing that they had come to a deal.

Although Macedonia has now ratified the agreement, it must also be approved by the Greek parliament. Tsipras has struggled to secure a majority in favor, but says he wants to put the deal before MPs in the coming weeks.

If it passes, Macedonia could join NATO before the end of the year.