Greek Prime Minister Alexis Tsipras has survived a no-confidence motion in parliament, pushed by the opposition over a deal between his government and Macedonia.

The motion, tabled by New Democracy, Greek's main opposition party, was rejected by a margin of 153-127 on Saturday.

Thousands of Greeks protested outside parliament against the accord with Macedonia, calling for Tsipras to resign. Police used stun grenades and tear gas to prevent them from entering the building.

Calling the deal “harmful” to Greek interests, the opposition party has accused the government of making too many concessions in the accord.

“Today, you are all mortgaging the future of the country,” opposition party leader Kyriakos Mitsotakis told the parliament ahead of the vote.

Then, addressing Tsipras, he said, “You will be the prime minister to say ‘yes’ to everything your predecessors said ‘no’ to.”

In response, the Greek prime minister praised the agreement at the chamber and said, “This is a deal I believe that every Greek prime minister would want.”

Tsipras accused the opposition leader of political opportunism and “of being hostage to the far-right wing of his party.”

The name dispute between Greece and Macedonia has been running for some 27 years, since the break-up of the former Yugoslavia.

Athens argues that the name Macedonia implies a territorial claim to a Greek region of the same name.

Under the terms of the deal, which is tentatively scheduled to be signed on Sunday, Macedonia would be known as the “Republic of North Macedonia,” and Greece would stop its objections to the renamed nation joining the European Union (EU) and the NATO military alliance.

But the deal still faces many difficulties before it can be assumed safe. It will have to be ratified at the parliaments of both Greece and Macedonia, and it will have to survive a referendum in the latter country, too.

Macedonian President Gjorge Ivanov has already declared that he will not approve the accord.