The nationalist Law and Justice party (PiS), which won an outright majority in 2015, has seen its grip on parliamentary power weaken in the years since. It is also roiled in conflict with the European Commission over the rule of law and faces wide opposition, especially in urban areas, to its position on cultural issues.
Earlier this month, the death of a pregnant Polish woman reignited debate over the country's near total ban on abortion, with protesters again taking to the streets.
Set against this backdrop, the drama that played out on the country's eastern border with Belarus -- while unsolicited by Poland and serious for all involved -- can be seen as a helpful distraction for the ruling PiS.
"This migration crisis is quite useful from the perspective of the domestic political agenda for the party because they are at the moment in trouble. And they have been in trouble for quite a time already, with the parliamentary majority becoming slimmer and slimmer," Piotr Buras, head of the European Council on Foreign Relations' Warsaw office, told CNN.
The right-wing party's ruling coalition narrowly controlled the lower house, the Sejm, until the summer, when three MPs defected, costing PiS its formal majority and forcing it to rely on the support of independents. The party had already lost control of Poland's upper house in 2019 elections, and President Andrzej Duda, backed by PiS, only narrowly won a second term last year.
Meanwhile, rising inflation is causing financial pain for many in Poland, and polling indicates support for the government has dropped in recent weeks, said Buras.
"I don't want to play down the situation because it is risky and serious, quite a difficult political situation because it involves a security conflict and a humanitarian crisis... but there is of course also an attempt to capitalize politically on this crisis," he said.
Judy Dempsey, editor of the Strategic Europe blog for the thinktank Carnegie Europe, agreed that the crisis had been "playing out very well" for the ruling party.
Support for the government had fallen, she said, amid protests over the death of the pregnant woman. But Dempsey added: "With this whole crisis on the Belarusian-Polish border, Law and Justice now is seen as a champion of protecting Polish sovereignty and, of course, protecting Europe."
Migrants settle for the night on Thursday, November 18, in a warehouse near the Bruzgi-Kuźnica crossing serving as an ad hoc processing center.
The decision by Poland's government -- which also opposed taking in refugees during the 2015 migrant crisis -- to hold firm on border security appears to have won wide domestic support.
Meanwhile, opposition politicians are in a difficult position because they cannot say they don't want to protect the border, Buras said, although they have criticized some of the measures taken by the government.
Warsaw has tried to keep the crisis from view, blocking the Polish side of the border to journalists, aid workers and doctors amid an extended state of emergency. That has not always worked to the Polish government's benefit: Some of the most compelling images of the crisis, such as Polish border forces using water cannons on desperate migrants, were captured from the Belarusian side of the border, where international journalists were able to operate. The government is now trying to pass legislation that would give it new powers when the state of emergency expires next month.
The crisis has also forced the EU to rally behind for Poland at a time of increasingly bitter dispute between the European Commission and Poland over the rule of law and the independence of the judiciary.
Late last month, the European Union's top court ordered Poland to pay a daily fine of €1 million ($1.2 million) for failing to suspend a disciplinary chamber for judges that the bloc says breaches EU law, just the latest in a series of conflicts.
Now, the European Commission and key European powers are speaking out in support of Poland as the defender of the bloc's eastern border.
In a call Wednesday with Polish Prime Minister Mateusz Morawiecki, German Chancellor Angela Merkel said Germany stands in "full solidarity" with Poland over the border crisis, German government spokesman Steffen Seibert tweeted.
Members of PiS have openly expressed their hope that the European Commission "will show more understanding for Poland and would apply a lighter approach to the rule of law issues because of this crisis on the border," Buras said.
Nonetheless, the political situation is "very volatile," he added, and the Polish government risks finding itself hemmed in by its fierce rhetoric on border security and unable to back down.
If the crisis abates, with migrants repatriated or no longer on the border, the extent to which the Polish government continues to benefit from the nationalistic fervor it has whipped up will depend in part on how effective the opposition is, Dempsey said.
Another factor to consider is those within Poland who do not share the government's desire to keep the migrants out, she said.
"We mustn't forget that there are civil society movements and nongovernmental organizations and decent people who want these migrants treated properly, (want) access to the border to give them help," she said. "Maybe this will backfire. The Polish government kept a lid on the reporting and didn't allow humanitarian agencies or the media to go to the border. So if this crisis does weaken, no doubt Law and Justice will try to keep the nationalist fervor going, but it cannot be sustained."
The clear losers in this crisis are the migrants, mostly from the Middle East, who paid large sums to traffickers on the false promise of an easy way to cross illegally into Poland and travel on deeper into Europe in search of a better life.
An unlucky few have died of cold in the freezing forests along Belarus' border. Others have opted to return home having gained nothing except debt; an Iraqi Airways evacuation flight left Thursday from Minsk carrying more than 400 Iraqis back to the cities of Erbil and Baghdad.
Belarusian border guards moved some migrants to shelter in a warehouse after tensions on the border flared into skirmishes Tuesday. The remainder followed on Thursday, leaving behind only remnants of the makeshift camp by the Bruzgi-Kuznica crossing where 2,000 or more people had been camped out.
Lukashenko's spokeswoman, Natalya Eismont, said Thursday that about 7,000 migrants were in Belarus. Those who remain insist on a humanitarian corridor being opened to Western Europe, primarily to Germany, Eismont said, according to Belarus state news agency BelTA.
According to the Polish Border Guard, there have been more than 35,000 attempts to cross illegally into Poland from Belarus since the beginning of August. Seven people had been found dead on the Polish side of the border as of Thursday.
Poland has been criticized by international aid organizations who say it is breaching international law by pushing asylum seekers who make it over the border back into Belarus, instead of accepting their applications for international protection. Poland stands by its actions, however, saying they are legal.
Meanwhile, some who have made it over the border into Poland have alleged brutal treatment at the hands of Belarusian security forces.
Western officials have accused Belarusian strongman leader Alexander Lukashenko of manufacturing the crisis to destabilize the bloc as retribution for sanctions over human rights abuses. The unanswered question is what Belarus now stands to gain from the standoff on the EU's eastern frontier.
EU leaders agreed Monday to impose a new package of sanctions on Belarus targeting "everyone involved" in facilitating the situation on Poland's border, EU foreign affairs chief Josep Borrell said.
The EU has also made clear its assistance will extend to humanitarian aid and help for migrants to return home -- but not to resettlement within its borders.
In a phone call Wednesday with Lukashenko, Merkel underlined the need to ensure "humanitarian care and return opportunities" for the people affected, her spokesman said.
Germany's caretaker Foreign Minister Heiko Maas has insisted that "the EU will not be blackmailed by criminals like Lukashenko" and says the bloc wants to find out the migrants' countries of origin in order to repatriate their citizens.
Dempsey is critical of the EU response, saying the bloc failed to agree on a common, united policy on migration after the 2015 refugee crisis and is paying the price for it now.
This crisis will doubtless be followed by another one, she said. "Migrants or refugees looking for safety or a better life will be exploited again and the Europeans still will not put together a proper, humane, practical policy -- and pushing up very heavily fortified fences is not a solution."
Some observers have pointed to President Vladimir Putin of Russia, the most important ally of Belarus, as being involved in stoking the turmoil. A buildup of Russian military forces near Ukraine's eastern border has deepened concerns over the potential for a wider geopolitical crisis.
Asked about any threat of war in an interview published Thursday by German newspaper Bild, Morawiecki said he hoped all parties would remain calm, but added that nothing could be ruled out.
"Lukashenko and Putin are obviously following a strategy to unsettle the West, to destabilize it. We don't know what else they are planning," the Polish Prime Minister told Bild. "It is also possible that the crisis on the border is only meant to distract from new military attacks that Putin is preparing in Ukraine."
Kremlin spokesman Dmitry Peskov on Thursday strongly rejected any suggestion that Putin had been using so-called "hybrid warfare" tactics in Europe.
"Russia does not wage any hybrid wars. We absolutely rule this out," Peskov told journalists.
Putin, too, has denied Russian involvement in the Belarus-Poland border crisis. "We have absolutely nothing to do with it. Everyone is trying to impose responsibility on us for any reason and for no reason at all," Putin told state broadcaster Russia 24.
Lukashenko's government has also repeatedly rejected claims it manufactured the border crisis.
Interviewed by CNN on Thursday, Belarusian Foreign Minister Vladimir Makei said accusations by European nations that Belarus had orchestrated the standoff were a "false assessment of the situation."
He instead blamed the EU, saying migrants had heard about the "privileges" neighboring EU countries had offered "migrants from Belarus" -- a reference to opposition and dissidents who have fled Minsk since disputed elections last year.
Radoslaw Sikorski, a member of the European Parliament and former Polish foreign minister and defense minister, told CNN's Hala Gorani that Lukashenko's gamble over the migrant crisis could backfire.
"Lukashenko is trying to repeat what President Erdogan of Turkey did, except that Turkey really had millions of Syrian refugees, and it really was a huge drain on Turkey's resources, and that EU agreed to pay some of that cost. Mr. Lukashenko has imported his migrants on purpose," said Sikorski, who is also a senior fellow at Harvard.
While Lukashenko would see the fact that he is receiving calls from Merkel as "a success for him," Sikorski said, the crisis could eventually cost him more than any fleeting legitimacy he has gained.
Actions taken by the EU and Middle East governments to stem the flow of migrants into Belarus are starting to have an effect and only small numbers are getting through to the EU, Sikorski said.
"I think, eventually, Lukashenko will have to conclude that it's a bigger problem for him than for the European Union," he said.