Ukraine faces dwindling reserves of ammunition, personnel and Western support. The counteroffensive it launched six months ago has failed. Moscow, once awash in recriminations over a disastrous invasion, is celebrating its capacity to sustain a drawn-out war.

The war in Ukraine has reached a critical moment, as months of brutal fighting have left Moscow more confident and Kyiv unsure of its prospects.

The dynamic was palpable last week, as Vladimir V. Putin casually announced plans to run for six more years as president of Russia, swilling champagne and bragging about the increasing competence of Russia’s military. He declared that Ukraine had no future, given its reliance on external help.

That air of self-assurance contrasted with the sense of urgency in this week’s trip to Washington by President Volodymyr Zelensky of Ukraine, who pressed Congress to pass a stalled spending bill that includes $50 billion more in security aid for Ukraine.

Speaking at the White House alongside Mr. Zelensky, President Biden said lawmakers’ failure to approve the package would “give Putin the greatest Christmas gift they could possibly give him.”

But Mr. Zelensky’s pleas fell flat, at least for now, with congressional Republicans, who are insisting that additional aid to Ukraine can come only with a clampdown on migration at the United States’ southern border. After meeting with Mr. Zelensky, Mike Johnson, the speaker of the House, said his skepticism had not changed.

The messages from Moscow and Washington illustrated the growing pressure on Ukraine as it shifts to a defensive posture and braces for a harsh winter of Russian strikes and energy shortages. Kyiv is struggling to maintain support from its most important backer, the United States, a nation now preoccupied with a different war, in Gaza, and the 2024 presidential campaign.

Looming over Kyiv’s prospects is the possible return to office in 2025 of former President Donald J. Trump, a longstanding Ukraine detractor and praiser of Mr. Putin who was impeached in 2019 for withholding military aid and pressuring Mr. Zelensky to investigate Mr. Biden and other Democrats.

Almost 22 months into the war, polls broadly have found waning United States support for continued funding of Ukraine, particularly among Republicans. A recent Pew Research Center survey found just under half of Americans believe the United States was providing the right amount of support to Ukraine or should be providing more.

Mr. Johnson said money for Ukraine required more oversight of spending, and “a transformative change” in security at the U.S. border with Mexico. “Thus far, we’ve gotten neither,” he said.

But the White House still has time to try to work out an agreement that includes border security, and Mr. Zelensky said he remained optimistic about bipartisan support for Ukraine, adding, “It’s very important that by the end of this year we can send a very strong signal of our unity to the aggressor.”

A rupture in U.S. funding would risk proving Mr. Putin correct in his longstanding conviction that he can exhaust Western resolve in global politics and conflicts. Though his government bungled the invasion of Ukraine in February 2022, Russia has regrouped, in part because Mr. Putin was willing to accept enormous casualties.

“Putin, soon after the initial offensive didn’t produce the results that Russia had hoped, settled in for a long war and estimated that Russia at the end of the day would have the biggest stamina, the longest staying power, in this fight,” said Hanna Notte, an expert on Russian foreign and security policy at the James Martin Center for Nonproliferation Studies.

Russia has adapted, pumping up its domestic production of ammunition and weaponry, and importing critical matériel from Iran and North Korea, all with the goal of sustaining a long war, Ms. Notte said.

“I think there was sort of a dismissiveness, ‘Let the Russians get together with these pariahs, with these global outcasts, and good luck to them,’” Ms. Notte said.

But that support has been meaningful for Moscow on the battlefield, she said, particularly with Iran helping Russia enhance its domestic drone production. Ukraine, meanwhile, is struggling to obtain a sufficient flow of ammunition and weaponry from the West, where nations aren’t operating on a wartime footing and face significant production bottlenecks.

Despite his advantages in numbers and weaponry, Mr. Putin also faces limitations, and military analysts say Russia is in no position to make another run at the Ukrainian capital, Kyiv, or other major cities.

Russia lost huge numbers of personnel in its offensive maneuvers in the past year, and won little territory apart from the city of Bakhmut. With Mr. Zelensky ordering his troops to build defensive fortifications along the front, Russia may continue to suffer heavy losses without gaining much in return.

Facing continued signs of displeasure with last year’s mobilization, the Kremlin appears loath to do another forced call-up before the Russian presidential election in March, if at all.

“What we have seen in this war is the defense usually has significant advantages,” said Steven Pifer, a senior fellow at the Brookings Institution and former U.S. ambassador to Ukraine.

Still, Ukraine, reliant on the West for weaponry and funding, faces short-term pressures that Russia does not. Kyiv’s allies don’t have the ammunition and equipment to arm another counteroffensive, making a major new campaign unlikely for most of 2024, according to analysts and former U.S. officials.

The United States is by far Ukraine’s most important backer, accounting for about half of its donated weaponry and a quarter of its foreign aid funding. The congressional fight, bogged down in a partisan dispute about border security, has unnerved many Ukrainians.

“Today, Ukrainians are beginning to suspect that the U.S. wants to force us to lay down our arms and conclude a shameful truce,” Yuriy Makarov, a political commentator for Ukrainsky Tyzhden, a Ukrainian magazine, said in an interview. “That the Ukrainians practically destroyed the professional army of Russia, which until recently was the main enemy of the United States, does not seem to be taken into account.”

The failure of this year’s counteroffensive has exacerbated political friction in Ukraine, most notably between Mr. Zelensky and the military chief, Gen. Valery Zaluzhny. A month after Mr. Zelensky publicly chastised the commander for saying the war had reached an impasse, the two have yet to appear together in public.

There are signs Russia intends to be more aggressive through the winter. After weeks of focusing attacks on the city of Avdiivka, Russia over the weekend began a general offensive along the eastern front, the commander of Ukraine’s ground forces, Gen. Oleksandr Syrskyi, told Ukrainian news media.

The fighting favors Russia’s greater access to artillery ammunition. Earlier this year, the NATO general secretary, Jens Stoltenberg, estimated that Ukraine fired 4,000 to 7,000 artillery shells a day, while Russia fired 20,000.

The United States has provided more than two million 155-millimeter artillery shells and brokered deliveries from other nations. But stocks in Western militaries, which had not anticipated fighting a major artillery war, are dwindling.

Ukraine also needs ammunition for air defenses, lest Russia’s volleys of exploding drones and cruise and ballistic missiles break through the air-defense blanket over the capital and key infrastructure.

The United States and its allies have provided a dozen or so types of air defenses, sophisticated NATO systems that have allowed businesses to open and cities to resume mostly normal rhythms of work and sleep. But as Russia fires thousands of cheap, Iranian-made Shahed drones, Ukraine’s air-defense ammunition is being exhausted.

A tipping point looms if Russian missiles can reliably penetrate gaps, hitting military targets like airfields and blowing up electrical and heating infrastructure to dampen economic activity with blackouts, deepening Ukraine’s reliance on Western aid.

“They can keep doing it as long as needed,” Tymofiy Mylovanov, a former Ukrainian minister of economy, said of the Russian assaults. Over time, diminishing political backing for Ukraine in the West provides an incentive to keep whittling away at Kyiv’s arsenal, he said. “If they feel Ukraine will lose support, they will try harder.”

Ukraine also faces challenges from the attrition of its personnel.

Kyiv does not announce mobilization targets or casualties, but a former battalion commander, Yevhen Dykyi, has estimated that Ukraine will need to enlist 20,000 soldiers a month through next year to sustain its army, both replacing the dead and wounded, and allowing rotations.

“Unfortunately,” he said, “with all the military tricks and technologies, some things cannot be compensated for by anything but sheer numbers.”