“There is no ownership of the issue by the government,” said Anna Wicha, a director at the Adecco Group, one of the largest employment agencies in Poland. “You ask how many Ukrainians are working here and they will say 500,000. But it is more than two million. And many may be going to Germany.”

For now, the government lacks a long-term strategy to expand the labor pool. Many experts and some opposition politicians in Poland say the situation will only be resolved if political leaders soften their resistance to migrants and embrace plurality. But at the national level, even talking about immigration can be politically lethal.

When Pawel Chorazy, the deputy minister of investments and development, said during a televised debate before the October local elections that “the inflow of immigrants to Poland needs to be increased to sustain economic growth,” he was met with scorn.

Joachim Brudzinski, the interior minister, said that Mr. Chorazy’s comments were “not a position of the government.” The prime minister, Mr. Morawiecki, said that Mr. Chorazy “got seriously ahead of himself.”

Then he fired him.

“Politicians are dancing on the line, well aware that you can wake up demons,” said Irena Kotowska, head of the center for demography at the Warsaw School of Economics. “It is easy to play into nationalist feeling with anti-immigrant rhetoric. But the reality of the need in the labor market is more and more clear every day.”

“This is a defining moment for the country,” she added. “Some decisions simply have to be made.”

Here in the central city of Lodz, the contradictions of Poland’s migration dilemma are evident. Unlike national leaders, however, the local mayor, Hanna Zdanowska, has embraced immigrants. When she ran last October, she called for an inclusive Poland that welcomed newcomers.

The governing party campaigned hard against her, but she won with 70 percent of the vote, which she credited in part to the city’s history of tolerance. It was once a manufacturing center of hundreds of red brick factories, with a diverse population of Dutch, English and German residents, and a strong Jewish contingent.