In 18 months of war, Ukrainian land has mostly changed hands in sudden bursts, with Russia snatching a mass of territory at the start and Ukraine recapturing chunks in dramatic counterattacks. Now 10 weeks into its most ambitious counteroffensive, with heavy casualties and equipment losses, questions have been growing about whether Ukraine can punch through Russian lines.

Despite grueling fighting, Ukrainian forces along much of the 600-mile front are moving forward, and commanders and veteran soldiers say they are in better shape now than six or 12 months ago.

“If a year ago we were conducting defensive operations and we had the task of holding back the enemy, now we have the ability to attack,” Col. Dmytro Lysiuk, commander of the 128th Mountain Assault Brigade, said in an interview in his frontline bunker last week.

Ukrainian officers are almost invariably upbeat in interviews. Even if the counteroffensive has yielded only mixed results so far, with Ukrainian troops slowed by dense Russian minefields and sustained firepower, they describe previous periods as being tougher than this one.

Their optimism is tempered by the deepening realization that the war looks likely to continue at least a couple of years more. Some commanders even talk of a permanent state of conflict.

But Colonel Lysiuk and other leaders interviewed in recent weeks point to what they describe as a number of encouraging changes. Their units are better trained and equipped than ever, thanks to billions of dollars of Western aid.

They have worked out how to manage the training of fresh soldiers and how to keep replenishing their ranks after losses, even while continuing to fight. Almost every unit has grown in professionalism and size: Battalions have turned into brigades, and volunteer groups into formal army units.

Longer-range Western artillery and, in particular, the cluster munitions recently provided by the United States, with some controversy, have been proving effective in destroying not only concentrations of Russian troops but also Russian armor and artillery systems.

Russian reinforcements have been holding back, reluctant to move into range of Ukraine’s guns, several commanders said.

“They can’t approach closer, or they will be destroyed,” said Lt. Ashot Arutiunian, the head of a drone unit of the Ukrainian Volunteer Army. Russia has resorted to other weapons, using more aviation bombs and missile strikes as a result, he said.

He showed video from his drones revealing damaged Russian armor. Vast craters gouged out of the earth by Russian aerial bombs and S300 missiles are visible in Ukrainian settlements all along the front line, where they have ripped up roads and smashed next to medical centers.

Even if it does not recapture territory quickly, the counteroffensive signals a shift of perspective for Ukrainian fighters.

For more than a year, units like the 128th Mountain Assault Brigade were ordered to hold the line along the Zaporizhzhia front, often a grim task of defending trenches and fortified positions under constant bombardment. Colonel Lysiuk was charged with rebuilding the brigade after it had taken heavy losses and lost its commander in December. It was back on operations in a week.

“It is tough,” Colonel Lysiuk said, “but the system is already tested.”

In June, his troops played a role in the first weeks of Ukraine’s counteroffensive, recapturing several villages in a strategic area near the Dnipro River and an intersection that leads south to the Black Sea and west to the Zaporizhzhia Nuclear Power Plant.

Colonel Lysiuk declined to say what his main tasks were then, but he said the brigade had fulfilled them all. “I’ll tell you after the war,” he said.

It is a measure of how tough the fighting has been that the advance amounted to just a few miles. The Russians moved up reinforcements, he said, and assaults on the next village have failed.

Yet Colonel Lysiuk was unperturbed. “It’s not a small job,” he said. “Some directions are more of a priority for development for a successful counteroffensive.”

Most of Ukraine’s seasoned commanders said they had learned from previous counteroffensives that Gen. Valery Zaluzhny, chief of the armed forces, and his top generals were adept at subterfuge and feints.

For months last year, Ukraine talked up its counteroffensive in the southern Kherson region and then surprised the world, and many of its own troops, with a sudden breach of Russian lines in the northeastern region of Kharkiv.

The Kherson counteroffensive unfolded by destroying Russian supply routes, which eventually forced the Russians to retreat from territory west of the Dnipro.

The two successful campaigns have given many Ukrainian soldiers and officers on the front confidence in General Zaluzhny’s overarching plan, even when troops receive a mauling, as did the new brigades spearheading the counteroffensive.

“We were disappointed, we thought they would punch quickly through to the sea,” said a 30-year-old deputy battalion commander of the 80th Airborne Assault Brigade, fighting on the eastern front. He gave only his call sign, Tysen, according to military protocol.

But Tysen said he had friends fighting in the south and they remained confident.

“Tactically, with cunning, with Western equipment, the Ukrainian armed forces are breaking through their defenses,” he said. “Success is just a question of time.”

Russian forces have mounted a fresh offensive in northeastern Ukraine toward the city of Kupiansk, but Ukraine units say they have managed to hold them at bay.

Tysen and other commanders said that the Russian forces they saw appeared to be in poorer shape than the Ukrainian ones.

“Compared to the beginning of the war, their equipment and personnel are in a very sorry state,” Tysen said.

On the southern front, soldiers and commanders said there were signs that Ukrainian artillery was wearing down Russian units facing them, largely thanks to American cluster munitions.

“We are using them quite effectively,” Colonel Lysiuk said. “They arrived mid-July. And we use them constantly.”

“We destroyed a lot of the enemy’s artillery in this time,” he said. “If before 20 enemy guns were working, now it’s two to four.” There are also signs, he said, that the Russians “cannot maintain constant combat readiness.”

Tactics mattered, too, said a deputy battalion commander of 129th Territorial Defense Brigade, who goes by the call sign Kherson.

A 41-year-old former government administrator who enlisted after the Russian invasion last year, Kherson led his unit in a combined assault on the village of Neskuchne at the beginning of the counteroffensive.

His men gained a foothold in the village and battled at close quarters for three days, he said.

“The Russians attempted counterattacks, tried to squeeze us out, to encircle us but everything happened as we envisioned,” he said. “We also had strong support from artillery and the higher command.”

As the Russian troops began to retreat, Russian forces fired rockets at the battlefield, killing their own men.

“They buried quite a lot of their own guys,” Kherson said.

Most Ukrainian commanders said their leaders had shown far more concern for the lives of their men than the Russian command for its troops. A few said hesitancy sometimes actually cost more Ukrainian lives.

A special operations forces officer, Oleksii, whose unit lost 15 men in four days of failed assaults on one village at the start of the counteroffensive, said, “If we had had harsher orders, that we had no option, we had to take the village, we would have.”

Instead, commanders delayed the operation, giving the Russians time to mine the trenches, he said. Then, when the first assault ran into difficulty, the commanders pulled back to regroup instead of sending in reinforcements.

“If you did it in one push, you would succeed and lose less people,” he said. “They thought, ‘we will try and lose less people,’ and now almost our whole group is in the hospital.”

How long such losses can be sustained by both sides may now prove critical to the war’s future course. Russia can draw from a population more than three times as large, but Ukrainian commanders repeatedly pointed to a crucial difference between the two sides: They were fighting to save their country.

“It doesn’t matter how long it is,” Kherson said. “It would be great if it ends in a week. If it is longer — we don’t have a choice.”

Oleksandr Chubko and Dyma Shapoval contributed reporting.