Athens, Greece - The government of Greek Prime Minister Alexis Tsipras has survived a vote of confidence by a whisker, keeping alive hopes it may ratify an agreement with former Yugoslav Macedonia that would rename the country North Macedonia.

"We shall have a confidence vote and we shall continue," Tsipras declared confidently before the vote in parliament on Wednesday.

His ruling Syriza party was left with a minority of 145 MPs in the 300-seat legislature on Sunday, after its junior coalition partner, Panos Kammenos, leader of the Independent Greeks party, walked out in disagreement over the Macedonia deal.

Tsipras called for a vote of confidence in order to rebuild his majority and serve out his full term to October.

Five MPs bolted from Independent Greeks to back him, and he won over another MP from the centre-right party, Potami, securing a 151-seat majority.

"The entire political scene is being reordered," said Deputy Defence Minister Fotis Kouvelis. "I believe the [Macedonia] agreement is cutting through the political system."

Kyriakos Mitsotakis, leader of the conservative New Democracy opposition party, saw the process of government majority-building quite differently during a heated debate bristling with allegations.

"This disgrace of borrowing MPs back and forth in order to create temporary majorities ... You have used foreign policy to undermine national unity," he accused Tsipras

"This isn’t called patriotism. It's called opportunism," Mitsotakis added.

For his part, Kammenos told Tsipras in parliament: "I ask you to stop the discussion on a vote of confidence and to announce that we are going to submit to the vote of the Greek people, and that we will respect that vote."

Tsipras has rejected the idea of a referendum on the Macedonia deal. He plans to bring it to a parliamentary vote, possibly as early as next week, but not all 151 MPs who gave him a vote of confidence support the deal.

Decades-long dispute

Greece and former Yugoslav Macedonia have been locked in a conflict over that country's name for 27 years. If ratified in Greece, the deal would remove a Greek veto on the country's membership in NATO and the European Union as North Macedonia, and could help speed up reforms by other applicants from the former Yugoslavia.

The deal was announced in June after a six-month negotiation, and former Yugoslav Macedonia ratified it last week.

When Yugoslavia broke up in 1991, its southernmost state declared independence as the Republic of Macedonia. Greece rejected that name, on the grounds that the new country could express designs on the northern Greek region of Macedonia, with which it shares a border.

After vetoing former Yugoslav Macedonia's entry into NATO in 2008, Greece agreed to settle on a name that contains the term Macedonia plus a qualifier. Many Greeks are against even that compromise; and many are alarmed that the agreement recognises Macedonian nationality, believing that it can easily be mistaken to imply an indigenous Macedonian ethnicity. That, they believe, could ignite competitive claims on ancient Greek history and heritage.

Greece's northern neighbour attempted to assuage such fears, saying in a diplomatic communique on Wednesday that "the term nationality refers exclusively to citizenship and does not designate or prejudge the question of the ethnicity of the citizens of North Macedonia."

"We are opposed [to the agreement] not because the government negotiated, but because it failed to understand what is non-negotiable," wrote 12 academics in an open letter to Tsipras.

Some MPs elected in the Greek region of Macedonia received death threats. Deputy Public Order Minister Katerina Papakosta offered her resignation after she received pictures of women with bashed-in heads. Tsipras did not accept it. A 63-year-old man was arrested in Athens on Monday, for allegedly sending threatening text messages to MPs' mobile phones.

Tsipras' legislative to-do list goes well beyond the signature Macedonia name deal.

The prime minister says he wants to amend the constitution to make cabinet ministers more accountable, increase the minimum wage and pass legislation protecting primary residences from foreclosure, as banks clamp down on nonperforming loans.