Greece's Alexis Tsipras faces a vote of no-confidence in his government by Saturday afternoon, while Macedonia's Zoran Zaev is contending with the refusal of the country's president to sign off on the deal if it's approved by parliament.
Zaev and Tsipras have agreed that the former Yugoslav republic should be renamed North Macedonia, ending a disagreement that had prevented it from joining international institutions such as NATO and had poisoned bilateral relations since the early 1990s.
But the dispute has roused strong nationalist sentiment in both countries. Critics on both sides of the border were furious, accusing their respective prime ministers of conceding too much, and protests are planned for both countries in coming days.
Greece has long demanded that its northern neighbor change its name, saying the term "Macedonia" implies territorial claims on its own northern province of the same name, birthplace of the ancient warrior king Alexander the Great, and usurps ancient Greek heritage and history.
Opponents in Greece object to any use of the term "Macedonia" in their northern neighbor's name.
Critics in Macedonia, meanwhile, see any modification of the country's name as a threat to their national identity.
In Athens, Tsipras faced a direct challenge to his left-led coalition government's survival after main opposition New Democracy submitted a motion later Thursday for a no-confidence vote.
"I have an obligation before the Greek people to try to avert the mortgaging of our country's future with an agreement that is detrimental to our national interests," New Democracy leader Kyriakos Mitsotakis said.
Tsipras has a four-seat majority in the 300-member parliament, but the name deal has led to a rift within the government itself. The stance of Defense Minister Panos Kammenos, who heads the coalition's junior partner, the right-wing Independent Greeks party, will be crucial.
Kammenos said before the deal was announced that he would oppose the agreement in a parliamentary vote, which would leave Tsipras dependent on support from political opponents to ratify it in parliament. It is unclear, however, whether his objections to the Macedonia name deal would lead him to bring down the government by voting against Tsipras.
Tsipras has said he does not expect that to happen.
The debate on the motion began on Thursday evening, and a vote is expected by Saturday afternoon at the latest.
Meanwhile in Macedonia, Zaev was faced with a refusal by the country's president, Gjorge Ivanov, to sign off on the deal if it's ratified by parliament. Such a refusal would delay the implementation of the deal, which is expected to be signed this weekend.
If the president refuses to sign, the deal would return to parliament for another vote. Ivanov would have to sign off on the agreement if it is passed a second time.
"We are Macedonians and we are here just to maintain and preserve what our ancestors left us," Ivanov said during a visit to neighboring Bulgaria on Thursday. "I swore to preserve the Constitution of Macedonia and that is my obligation."
But the visit was overshadowed by the deal with Greece. Bulgaria's prime minister and foreign minister refused to hold meetings with Ivanov because of his opposition to the name deal.
And Bulgarian President Rumen Radev said after talks with Ivanov that, in the light of the deal with Greece, Bulgaria should seek to revise aspects of the friendship pact it signed with Macedonia last year.
Macedonia's conservative main opposition party, which opposes the agreement, called for a protest in the southern town of Bitola on Sunday - when the foreign ministers of Greece and Macedonia are expected to sign the deal near the two countries' border, close to Bitola.
In Macedonia's capital, Skopje, opponents of the name-change protested peacefully outside parliament for a second evening. Greek opponents of the agreement plan a protest in Athens on Friday.
Jasmina Mironski in Skopje, Macedonia, and Nicholas Paphitis in Athens contributed.
Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.