After a year of ever-closer cooperation between Poland and the United States to ensure the flow of Western weapons into Ukraine, the Polish Foreign Ministry last month summoned the U.S. ambassador in Warsaw to discuss an urgent matter: a television documentary about a dead pope, John Paul II.

The documentary, which delved into the Polish-born pontiff’s negligent response to the sexual abuse of children by priests in Poland in the 1960s and 70s, had just been aired by an American-owned Polish-language TV channel, TVN24.

It had no bearing on the war raging next door in Ukraine but it may figure prominently in a matter of great importance to Poland’s right-wing governing party: how to stay in power.

Facing a general election later this year amid soaring inflation and widespread economic pain, the party, Law and Justice, has seized on the documentary and the outrage it caused among many Polish Catholics. The party is promoting itself as a fearless defender of a revered national hero, whom the Church has declared a saint, even if that means scolding the United States, Poland’s close ally and the guarantor of its security.

For weeks now, fury over the documentary, amplified to earsplitting volume by the governing party’s media machine, has dominated news cycles in Poland. Last Sunday — Palm Sunday, and the anniversary of John Paul II’s death in 2005 — conservative politicians and thousands of ordinary people marched through Warsaw to protest what state-controlled media outlets have presented as an assault by godless traitors on a man the chairman of Law and Justice described as “the greatest Pole in our history.”

The furor has delivered a big boost to the governing party’s electoral prospects, according to Ewa Marciniak, a political science professor at Warsaw University. “It has distracted the focus from economic problems like inflation and put the focus on values connected to John Paul II,” she said.

Unlike its bickering opponents, divided between centrists, free market liberals and often anticlerical progressives, Law and Justice “knows exactly who its voters are” and how to mobilize them, Ms. Marciniak said.

TVP, a state broadcaster controlled by the party, responded to the TVN24 documentary by ending its widely watched news bulletin each evening with a reverential tribute to John Paul II featuring excerpts from his papal homilies. A giant image of him has been projected onto the facade of the presidential palace in Warsaw. The central bank has issued bank notes with John Paul II’s picture, and Parliament passed a resolution denouncing the “disgraceful media campaign” against him.

Still, Ms. Marciniak said she was shocked that the Foreign Ministry went so far as to call in the U.S. ambassador, Mark Brzezinski, to complain about a TV documentary. That, she said, was a “cringe-worthy faux pas,” even if it did trumpet the government’s loyalty to the pope’s memory.

The ministry initially said it had “summoned” the ambassador to discuss what it called the actions of a broadcaster that “are identical to the goals of hybrid war” and risk “leading to divisions and tensions in Polish society.” Accused of putting domestic politics over a vital foreign relationship, the ministry quickly amended its statement to say it had simply “invited” the ambassador.

Ned Price, a spokesman for the State Department, declined to detail what Mr. Brzezinski had been told, saying only that “the ambassador was at the foreign ministry for discussions.”

TVN24, the popular private channel that broadcast the documentary, is owned by Warner Bros. Discovery and has long been in the sights of Law and Justice, which, since coming to power in 2015, has turned Poland’s public broadcasting system into a highly partisan bullhorn and fumed at independent media outlets outside its control.

Ignoring complaints from Washington, the governing party and its allies passed legislation in 2021 restricting foreign ownership of Polish media. But the effort collapsed when Poland’s president, Andrzej Duda, unexpectedly broke with his party and used his veto power to block it. Poland, he explained, could not afford to shred its reputation among allies as “an honorable nation.”

Thrust into the spotlight by the war in Ukraine and its role as an indispensable transit route for many of the weapons being used against Russian forces, Poland has basked in recent months in approving attention from abroad. President Biden has visited Warsaw twice since Russia began its full-scale invasion, praising Poland for welcoming millions of Ukrainian refugees and for providing robust support for Ukraine’s efforts to beat back Russian forces.

Poland’s new role as an important geopolitical player, however, has shown little sign of widening the governing party’s narrow political horizons.

“For Law and Justice absolutely everything, including foreign policy, is subjugated to domestic political games,” said Jakub Majmurek, a prominent media commentator on Polish politics and culture.

And nobody, he said, is better at these games than the chairman of the party, Jaroslaw Kaczynski, a reclusive 73-year-old bachelor who lived with his mother until her death a decade ago.

Mr. Kaczynski has been particularly skillful at identifying wedge issues that rally his party’s conservative, predominantly religious and rural base, and catch opponents off balance. In 2019, Mr. Duda seemed to be floundering in his campaign for re-election, until Law and Justice branded his rival, the liberal mayor of Warsaw, as a champion of L.G.B.T. rights, casting the election as a referendum on traditional Christian values. Mr. Duda won.

The documentary about John Paul II has provided a new opportunity to turbocharge Poland’s culture wars. While his mishandling of clerical sexual abuse as pope has come under harsh scrutiny in recent years, the documentary looks at his less-examined record as Archbishop of Krakow from 1964 to 1978, when Poland was a Soviet satellite state firmly under Moscow’s thumb.

While church attendance has been declining for decades in Poland, particularly among young people — only a fifth of whom now attend Mass regularly — more than 90 percent of the population identifies as Catholic, a cultural as much as religious allegiance. This makes even people who don’t go to church sensitive to criticism of John Paul II, who is revered by many Poles more for his role in fighting communism and as source of national pride.

Cardinal Karol Wojtyla, then-archbishop of Krakow, Poland, arriving at a gathering at the Vatican in 1971.Credit…Gianni Foggia/Associated Press

“The paradox is that Law and Justice is fighting a war against secularization it has already lost, but it can still win elections by using religion,” Mr. Majmurek said.

A few days after the TV station aired its documentary last month, a Dutch journalist, Ekke Overbeek, added fuel to Poland’s culture war fires with the publication in Polish of a book titled “Maxima Culpa. John Paul II Knew.” The book, based on material from communist-era police archives — church archives are mostly closed — and interviews, detailed cases in which, it reported, John Paul II covered up the abuse of minors by priests during his time in Krakow.

Mr. Kaczynski denounced questions about the pope’s handling of abuse as “disgusting manipulations” and an “unprecedented campaign of innuendo and slander against the person of Saint John Paul II” by leftists aimed at “destroying traditional values” and “building a brave new world on their ruins.”

The Palm Sunday march, organized under the auspices of the Center for Life and Family, an anti-abortion organization, ended with a Mass in Warsaw’s Old Town and steered clear of overt party politics, though it included heavy doses of Polish nationalism. “God, honor, fatherland,” a patriotic motto, featured on signs held aloft by some of marchers.

Jerzy Kabinski, a retired businessman who took part, said he had traveled with his wife from eastern Poland to join the march because he wanted to show support for the late pope and stand up against “leftists who want to destroy our nation and its values.” John Paul II, Mr. Kabinski said, “is our guide in life” and worthy of respect not only as a religious leader but also for his role in helping Poland topple communism in the 1980s.

“Thanks to him we are free,” he said.