The commander of Ukraine’s ground forces visited soldiers in Bakhmut for the second time in less than a week on Friday, a reflection of the precarious position Ukrainian forces find themselves in as they cling to their positions in the battered city.

Col. Gen. Oleksandr Syrsky, the commander, ‌warned‌ in a statement that Russia was throwing “the most prepared units” into the fight and ‌said ‌that he was assessing “problematic issues related to increasing the defense capability of our units on the front line.”

Russia launched its offensive to take Bakhmut in August, and the fighting has rarely relented since. ‌Though Ukraine has put up a stiff defense, in recent weeks Moscow’s forces have made gains that put the critical roads in and out of the city in jeopardy.

Those roads are vital to resupplying the troops, but also for a retreat if needed.

For the moment, commanders say they have pushed Russian troops back a bit, reducing the threat of artillery fire on a main highway that leads southwest out of the city.

Ukrainian commanders say they want to hold on as long as they can, degrading enemy forces even if they ultimately cannot hold the city. The challenge is timing, ensuring that if a withdrawal becomes necessary‌, they can carry it out in a way that‌ minimiz‌es losses.

Yevgeny Prigozhin, the founder of the Wagner mercenary force that has helped lead Russia’s assault on Bakhmut, released a video on Friday taunting the Ukrainians, claiming they only had one road left to escape and urging President Volodymyr Zelensky to order a withdrawal.

“The pincers are closing,” he said.

It is not the first time Mr. Prigozhin has made bold proclamations, many of which have proven false. But the precariousness of the Ukrainian grip on Bakhmut has been evident for weeks.

On Friday, one commander of a drone unit said that he and his soldiers were being pulled out. It was unclear if that was to allow them to rest after grueling battles, or for something else. He gave no further details.

Here are some of the basics of the Ukrainian strategy and what the battlefield looks like.

Very high.

The battle for Bakhmut is already the longest sustained Russian assault of the war. Both sides have suffered grievous losses. Neither side divulges its casualty numbers, but Ukrainian commanders claim they are killing as many as 800 Russians a day. Ukrainian medics at the front say they are treating dozens of their own wounded soldiers every day, an indication of the intensity of the fighting.

“The task of our forces in Bakhmut is to inflict as many losses on the enemy as possible,” Volodymyr Nazarenko, a deputy commander in the National Guard of Ukraine, told Ukrainian NV Radio on Friday. “Every meter of Ukrainian land costs hundreds of lives to the enemy.”

Ukrainian officials point to the battles for Sievierodonetsk and Lysychansk in the summer to explain their strategy. Adjacent cities located in the Luhansk region in the east, they were both bombarded for weeks before they fell. At the time, many questioned the wisdom of the Ukrainians’ holding on to what were essentially dead cities given the staggering loss of life. At the height of the battle, Ukrainian officials estimated that hundreds of Ukrainian soldiers were being killed and wounded every day.

But Col. Serhiy Cherevaty, a spokesman for Ukraine Eastern command, said that in holding off the Russian military in those cities for so long, Ukraine had been able to severely degrade the enemy’s fighting capability, paving the way for a successful counteroffensive in the fall.

The gravest risk for Ukrainian forces is that they will be encircled and forced to surrender or be killed. But the more immediate risk is that Russia will make it impossible to resupply the Ukrainian fighters in and around Bakhmut.

There are three main arteries that provide vital lifelines for the thousands of Ukrainian soldiers fighting in and around the city. Russian forces have cut off one of the routes and have been closing in on the other two main roads, according to soldiers and volunteers who have regularly used the route.

They say the road from Bakhmut to Chasiv Yar — just a few miles to the west — now comes under regular shelling and Russian forces are launching assaults to try to close it off. To the southwest, where the Ukrainian counterattack has pushed the Russians back somewhat, the main highway is still under heavy shelling ‌but is safer than it was, according to commanders in the Bakhmut area.

“The enemy tries to advance and conducts assaults not even every day, but almost every hour,” said Mr. Nazarenko, the deputy commander in Ukraine’s national guard, who travels that road.

But he said that the Ukrainian defenses of the supply line “stand firm.”

If that changes — which it could any day, in either direction — then the calculations of Ukraine’s military and political leaders will also probably shift.

Ukrainian reinforcements were sent in this week, according to Ukrainian commanders, but it is unclear if they are there to help cover a retreat or to try to hold on to the city even longer.

Bakhmut has been on fire, smoke rising from burning buildings. Explosions have been constant, with artillery thundering in from all directions. Ukrainian and Russian drones have circled the skies, finding targets and dropping bombs.

That was the scene the last time reporters from The New York Times visited the ruined city this winter. It is difficult to assess what is happening now — recent attempts to collect satellite imagery have been hampered by cloud cover. But judging from videos and statements posted by Ukrainian soldiers and volunteers whom The Times has interviewed over the course of the battle, it is much the same, only more so.

The Russians appear now to be counting on leveling so many buildings that the Ukrainians have few places in which to shelter and fire on the Russian troops.

Outside the city, where Ukraine has established rings of defensive positions meant to stop Russian assaults from the north, east and south, the fighting is constant. Ukrainian forces target Russian armored vehicles in open plains and hiding in forests. Russia sends waves of infantry on foot to storm Ukrainian trench lines.

Ukrainian officials also say that when they withdraw, assuming they do, it will mean the Russians will just move on to destroying the next city on the map. That would be Chasiv Yar.

Ukraine still controls about half the Donetsk region, and military analysts say that Moscow will probably struggle to use Bakhmut as a springboard to sweep across the region. Ukraine’s defensive lines would move back, and the grueling war of attrition would most likely grind on, just a few miles to the west.

Pushing out the Ukrainians, however, would give the Kremlin the ability to promote the battle as a victory after months of demoralizing setbacks.

Ukraine has been preparing for the fall of Bakhmut for months, even as it hangs tight to the city. Its forces are fortifying their positions in Chasiv Yar, and aid workers and volunteers have stepped up their efforts to evacuate the civilians who remain in the town and those who manage to make it out of Bakhmut, where an estimated 3,000 civilians remain.

The Ukrainian drone commander who was told to withdraw said this week that the battle had been growing more difficult by the day.

“The price of holding it is supreme,” the commander, who goes by the call sign Magyar, said in one of his many video messages broadcast on Telegram. “And it is getting harder and harder to hold it.”

Thomas Gibbons-Neff, Carlotta Gall and Natalia Yermak contributed reporting.