ATHENS, Greece -- Greece's left-wing prime minister narrowly won a confidence vote in parliament late Wednesday days after the governing coalition he leads collapsed over an agreement to end a long-running dispute over neighboring Macedonia's name.

Lawmakers voted 151-148 on a motion called by Prime Minister Alexis Tsipras, giving his government the minimum it needed in the 300-seat legislature to survive. During a heated debate earlier in the day, Tsipras argued the Macedonia deal would bolster stability in Europe's Balkan region.

"At the critical times, we all must have a clear position," he said before the vote, which coincided with the one British leader Theresa May won over her Brexit deal with the European Union.

The leader of a small Greek nationalist party, Panos Kammenos, quit as defense minister in Tsipras' government last weekend over the proposed agreement with Macedonia. The deal calls for the country to be renamed North Macedonia in exchange for Greece lifting its objections to its young northern neighbor joining NATO and the European Union.

Several members of Kammenos' party voted to support the government. Along with independents and opposition dissenters, they gave the 44-year-old Tsipras six votes from outside his party, allowing him to remain in power. His term ends in October.

Greece's western allies also strongly back the deal Tsipras and Macedonian Prime Minister Zoran Zaev agreed to in June. Russia remains strongly opposed to the prospect of Macedonia's NATO membership.

Tsipras has strongly defended his efforts to end the 27-year dispute with Macedonia over that country's name, which Greece long argued implied designs on its own Macedonia and on Greek cultural heritage.

Tsipras had said he would seek to get the Greek parliament's approval of the name-change deal soon after the confidence vote.

Hardliners in both countries claim the deal conceded too much to the other side. But Greek government officials say they are optimistic the agreement will be ratified in Athens even though most opposition parties reject it.

In Greece, sentiment is particularly high in the northern Macedonia province, where opponents say their regional identity and heritage is being signed away. Posters have appeared in recent days with pictures of local lawmakers who back the deal and the caption: "Will you betray our Macedonia?"

Four people were arrested Wednesday over the posters in the northern towns of Grevena and Kozani and charged with breaching advertising laws and traffic codes.

Opponents of the name-change deal are planning a protest rally in Athens on Sunday.

———

Costas Kantouris in Thessaloniki, Greece contributed

———

Follow Gatopoulos at http://www.twitter.com/dgatopoulos