Listening to the daily thud of artillery hitting nearby towns, a school principal in southern Ukraine appealed to parents for donations for a new bomb shelter.

A soldier and his girlfriend gave up hope that the war against Russia would end soon, and decided to get engaged, despite not having any idea when he might come home.

A woman, depressed for months about the instability, decided to stop worrying and just imagine that peace would come next spring, maybe, along with the flower blossoms.

“I felt so helpless,” said the woman, Tetyana Kuksa, who works at a market in Kyiv, Ukraine’s capital. “I am dreaming it will stop.”

With Ukraine’s army stalled in trenches along the front line and a sense that weaponry from allies arrived too late and will now begin to dwindle, Ukrainians are increasingly pessimistic over prospects for a quick victory, polling and interviews show. Hopefulness, a linchpin of Ukraine’s fight against a much more powerful foe, has been dented.

The result is a nation preparing, with a sort of sober resignation, for life with war as a constant, and no end in sight.

It is a trend, not a waving of the white flag. The vast majority of Ukrainians remain defiant, support President Volodymyr Zelensky and trust their military. The spirit that drove Ukrainian bartenders, truck drivers and university professors to enlist in the army after Russia invaded in February 2022 is still evident daily.

But recent polling shows that it has faded by several measures.

Readiness for a negotiated settlement with Russia has increased in a small but still significant way for the first time since the invasion began, polling and focus group studies show, rising to 14 percent from 10 percent, though the vast majority of Ukrainians still staunchly reject trading territory for peace.

Ukrainians were most hopeful, polls indicated, last winter, in the run-up to the counteroffensive in the south. Trust in all institutions other than the army has since dropped, according to a survey by the Kyiv International Institute of Sociology, one of the country’s leading pollsters. Trust in government fell from 74 percent in May to 39 percent in October, the period when the Ukrainian offensive began and then petered out, the institute found.

Ukraine’s last significant military gain, the reclaiming of Kherson city, came a year ago. Despite months of bloody trench fighting and tens of thousands of casualties, little land has changed hands since.

This past week, Ukraine’s top military commander, Gen. Valery Zaluzhny, provided a blunt assessment of the country’s near-term prospects, telling The Economist that the fighting had settled into a “stalemate.” Mechanized assaults are failing, he wrote, and without more advanced technological weaponry, a new, long phase of war would settle in.

It was a conclusion that Andriy Tkachyk, the mayor of the village of Tukhlia, in western Ukraine, had already drawn after volunteering to drive the bodies of soldiers from the front to their hometowns and organize funerals. In conversations, he said, he heard of difficult, bloody battles just to hold positions, and complaints by war-weary soldiers that they lacked ammunition.

“The boys who are at the front are physically and psychologically tired,” Mr. Tkachyk said. “Very tired. This war will last a long time.”

“Frustration is rising,” he said, including a sense that poor village boys are dying while civilians from wealthier families in the cities find ways to avoid conscription. Draft dodging is on the rise, as men hide to avoid receiving notices or try to bribe officials at local recruiting centers.

“Every village has graves,” he said. “The situation is bad.”

Ukrainians who were once quick to express healthy skepticism about their government rallied around the flag when the full-scale war started, elevating trust in Mr. Zelensky, the army and nearly all institutions of their threatened state.

That, too, is fading with the stalled military advance, the daily shelling and the mounting casualties.

Trust in Mr. Zelensky, though still shared by a majority of Ukrainians, has slumped, falling to 76 percent in October from 91 percent in May, the Kyiv International Institute of Sociology survey showed. Other polls have shown Mr. Zelensky’s job approval ratings at 72 percent.

Only 48 percent of Ukrainians say they trust the government-controlled television news channel, called the Telemarafon, which aired upbeat reporting of the military operation in the south, the institute’s survey found. The programming was intended to bolster Ukrainians’ morale as their army fought to push Russian forces from the coast of the Sea of Azov, but its divergence from events on the ground ended up prompting skepticism among Ukrainians.

“We should be honest,” Anton Hrushetsky, the director of the Kyiv institute, said in an interview. “People are becoming pessimistic.”

Stress is rising, he said, as Ukrainians want to move on with their lives in safety but see no promising prospects.

The pervasive sense of insecurity in Ukraine, said Mr. Hrushetsky, is leading Ukrainians to search for somebody to blame.

“People don’t describe it as a failure, and they do not blame the army,” Mr. Hrushetsky said of the stalled effort to reclaim territory, or, in the words of General Zaluzhny, the “stalemate” in the war.

But anger is rising toward government corruption at home and toward the country’s Western allies, who, in Ukrainians’ view, have slow-walked the delivery of weapons.

A survey commissioned by the European Union found the number of Ukrainians who say the West does not want Ukraine to win the war has doubled, to 30 percent from 15 percent, over the past year.

Fault lines are emerging, too, in the country’s domestic politics. Those who support Mr. Zelensky are more inclined to blame allies, while Mr. Zelensky’s political opponents draw attention to corruption at home.

Small protests broke out in October, revealing points of stress. Families of Ukrainian soldiers missing in action pressed the government for answers in a street demonstration in Kyiv. And in the capital and other cities, families of soldiers who have been in the army for the duration of the war protested to demand the government rotate them off the front. “It’s time others stepped up,” they chanted on Maidan Square in Kyiv.

Thwarted expectations of a summer military success largely lie behind the trend toward pessimism, the polling suggests.

After a winter of darkness last year when Russia targeted electrical power plants and transformer substations, leading to blackouts, Ukrainians felt hopeful as the power returned in the spring.

“We said, ‘Well, we managed, everything is over, now there will be a counteroffensive,’” said Andriy Liubka, a Ukrainian novelist. “We had this inspired optimism.”

Now, families hear from soldiers in the trenches, where autumn rain is drenching them and “life is like something from past historical eras” of hardship and violence, Mr. Liubka said.

The trenches are yielding a steady stream of dead and wounded. In their most recent estimate, U.S. officials said in August that about 70,000 Ukrainians had been killed in the war, and that more than 100,000 had been wounded. The Ukrainian government does not provide casualty figures.

Many Ukrainians look with alarm at the politicization of military aid in the United States, Slovakia, Poland and other countries.

“A stage of great anxiety” has set in, Mr. Liubka said.

And yet any concession to Russia risks leaving millions of Ukrainians under occupation, facing potential repression, arrest and execution.

In the village of Blahodatne, in the Kherson region of southern Ukraine, a school director, Halyna Bolokan, deemed it safe enough to reopen the elementary school, despite the daily nearby explosions. But she took pains to refurbish the basement as a bomb shelter, with donations from the community.

“I am using strength to put a smile on my face,” she said. “People are now dreaming about our new bomb shelter.”

Serhiy Mykhailyuk, a soldier in the air-defense forces, walked on a recent blustery fall day in Kyiv with his fiancée, Yekaterina Bordyuk. “Of course, there is sadness every day he is not home,” Ms. Bordyuk said. “But the war will take a lot of time, not one or two or three years. We kind of got used to it.”

Maria Varenikova contributed reporting.