Russian forces sent fleeing by Ukraine’s recent counterattack are attempting to establish defensive positions and regain their footing. It is a difficult pivot even under ideal conditions, and so far Moscow’s forces show signs of struggling to adapt.

Battlefield setbacks are just one challenge facing the Kremlin as it tries to secure its territorial gains in Ukraine and fend off nascent criticism at home. Kyiv’s forces this month have retaken dozens of settlements and more than 3,500 square miles of Russian-controlled ground in the northeastern Kharkiv region, according to government officials.

Ukraine continued attacking Russian-held territory on Friday, hitting the easternmost parts of the Kharkiv region and other parts of eastern Ukraine. They hope to capitalize on those gains to advance their offensive in the southern city of Kherson. Attacks on government buildings in Kherson and the eastern city of Luhansk killed two Moscow-installed officials, local Russia-backed authorities said.

On the battlefield over recent weeks, Russia has lost hundreds of heavy military vehicles, including over 100 tanks, according to open-source intelligence reports. It also lost several pieces of classified electronic-warfare equipment that are now in the hands of Western-allied forces. Many Russian soldiers—in the thousands, by some estimates—have either surrendered or will become prisoners of war.

Ukraine’s advance will also allow its rockets to hit targets deeper within Russian-controlled areas, potentially in occupied parts of Ukraine such as Crimea and in Russia itself.

Within Russia, criticisms of President Vladimir Putin and his regime remain limited but are growing. Spreading wariness about the war could limit Mr. Putin’s options for responding, such as a limited mobilization or a draft, which under Russian law likely would require an outright declaration of war.

“We gave up the strategic initiative,” said Vladimir Soloviev, a popular host on state-run television this week.

Russian TV pundits acknowledged Ukraine’s successes in its counteroffensive, which they credited to U.S. intelligence, Western weapons and even fighters from the North Atlantic Treaty Organization disguised as mercenaries. They showed clips alleging cruel punishment of Russian sympathizers by Ukrainian forces in retaken areas as supposed proof of Ukrainians’ Nazi-like nature.

A Russian tank abandoned in the Ukrainian town of Izyum following Moscow’s retreat.

Photo: GLEB GARANICH/REUTERS

Russia still retains significant forces deployed in and around Ukraine and vast stores of weaponry and ammunition, giving it the potential to react and hit back. While Kyiv has seized the initiative in routing some of Moscow’s front-line troops, it is far from uprooting all Russian forces occupying its territories.

Ukraine could also face more opposition in pushing further into Russian-controlled regions, military analysts say. Kyiv’s recent gains near Kharkiv, in the northeast, were achieved using surprise and by finding weak points in Russia’s long and thinly protected front line, according to soldiers involved in the fight. Achieving such surprise again may be difficult and Ukrainian forces are advancing into regions where Russian forces are more dug-in than near Kharkiv.

Eastern parts of Ukraine under pro-Russian occupation since 2014 have been bound more closely to Moscow, so Kyiv’s forces may receive less support from local populations there than they have so far.

“I think it does become somewhat harder for the Ukrainians going forward,” said Dmitry Gorenburg, a Russian military expert at CNA, a defense-research organization in Arlington, Va. As the area Russia is defending shrinks, its ratio of forces to territory should rise, he said.

Working against Russia is low morale, an inflexible military command structure and equipment that has proved to be poorly maintained. Energized Ukrainian forces, who have shown themselves to be nimble in battle, are using new and well-kept equipment.

Since launching its large-scale invasion of Ukraine in February, Russia has been slow to react to battlefield intelligence and developments, say Ukrainian and Western analysts. Over recent weeks they had signs that Ukraine was preparing to attack near Kharkiv but failed to prepare, Russian and Ukrainian analysts say. That rigidity bodes ill for Moscow’s ability to handle its sudden and unexpected setbacks, they say.

SHARE YOUR THOUGHTS

What do you think will bring the war to an end? Join the conversation below.

“Adapting while in combat is going to be difficult for Russia,” said James Hackett, a military expert at the International Institute for Strategic Studies in London.

Igor Girkin, a military observer and former intelligence officer who commanded irregular Russian forces in Donbas in 2014, wrote in his increasingly popular Telegram channel that Ukrainian success came thanks to failures in how senior Russian leadership conducted the war.

If Russian forces continue as they have since February, he wrote, “we will, in the end, suffer a crushing defeat in this war.”

Russia’s combination of battlefield losses and growing internal dissent could increase pressure on Moscow to double down on its fight, analysts said.

“Russia will have to show something for this,” said Emily Ferris, a specialist on Russian politics and its military at the Royal United Services Institute, a think tank in London.

Firefighters respond to missile strike in a Ukraine-controlled town in the Donetsk region on Thursday.

Photo: juan barreto/Agence France-Presse/Getty Images

Over recent days, Russia has attacked several civilian targets in Ukraine, including a dam near President Volodymyr Zelensky’s hometown, Kryviy Rih, that caused extensive flooding. But such destruction won’t shift battlefronts.

“The one path that Russia does have available is boosting the costs it can impose on its adversaries, both in Ukraine and in Europe,” said Samuel Charap, a Russia expert at Rand Corporation. “But that’s not taking territory.”

If Russia suffers calamitous losses, Mr. Putin could resort to biological or nuclear weapons, some analysts say, though many military experts say their use doesn’t seem likely soon.

Seeking to regain the initiative, Russia has been recruiting forces, including from prisons. But training new recruits takes time and requires trainers, and Russia faces manpower shortages across its ranks, soldiers have said. Without significant numbers of new troops, Russia could lack sufficient forces to repulse further Ukrainian attacks.

“The more the Ukrainians can keep up the pressure, the harder it’s going to be for the Russians,” said Mr. Hackett.

Craters scar a field flanking a road near Izyum, in Ukraine’s Kharkiv region.

Photo: Kostiantyn Liberov/Associated Press

Adding to Russia’s troop shortage are its losses of weapons and ammunition. Ukrainian troops over recent days have posted on social media many images of abandoned vehicles and storerooms full of shells. Ukraine has faced shortages of shells and rockets for its Soviet-designed artillery.

“The losses are bad for Russia in two ways,” said Mr. Gorenburg. “Russia doesn’t get to use the equipment, and Ukraine gets to use it.”

Also damaging to Russia in the mid-to-longer term will be losses of advanced technologies. Ukrainian forces have posted images of abandoned or captured equipment including pods for fighter-jet planes that jam opponents’ electronic defenses and vehicles filled with sophisticated electronic-warfare systems.

Once Ukrainian and Western military-electronic experts disassemble and analyze the units, they will be able to engineer equipment to thwart them.

“I think it’s a bonanza for Western defense-intelligence agencies,” said Mr. Hackett.

Russia will struggle to update or replace the lost equipment because Western sanctions are limiting Moscow’s access to advanced electronics. And if word spreads that Russia’s advanced defenses have been compromised, its prospects of selling such gear in export markets will diminish, further weakening its arms industry, analysts say.

Write to Daniel Michaels at daniel.michaels@wsj.com and Yuliya Chernova at yuliya.chernova@wsj.com