Russian and Ukrainian forces were locked in fierce fighting around the eastern frontline town of Avdiivka for a fourth straight day on Friday, in one of Moscow’s biggest military offensives in months.

Ukraine’s top military command said that it had repelled more than 20 attacks over the past day around the town, a linchpin of regional defenses whose capture by Russia would ease the way to the nearby, larger cities of Pokrovsk and Kostiantynivka.

Local officials described round-the-clock fighting and residential buildings that had been reduced to rubble by shelling, with heavy bombardments and the deployment of large numbers of troops and tanks by Russian forces.

“It was a hot night in Avdiivka,” Vitaliy Barabash, the head of the town’s military administration, told Ukrainian television, adding that Russian forces were closing in on the area with infantry and striking with artillery. “The assaults do not stop, day or night.”

The attack on Avdiivka, already devastated by Russian shelling during the war, may indicate that Moscow is trying to regain the initiative on the battlefield, after months on the defensive after Kyiv launched its counteroffensive this summer in the south.

“The enemy sees Avdiivka as an opportunity to gain a significant victory and turn the tide of hostilities,” Oleksandr Shtupun, a spokesman for Ukraine’s southern forces, said on Thursday.

But as much as Ukrainian forces have struggled to break through Russia’s formidable defensive lines in the south, it will not be easy for Russian troops to overrun Kyiv’s heavily fortified positions around Avdiivka, which has been on the front line since Russian-backed militants seized territory in eastern Ukraine, including the nearby city of Donetsk, in 2014.

Ukraine’s military has claimed that many Russian troops and armored vehicles have already been eliminated in the assault, in which Russian forces have captured less than two square miles, according to geolocated footage analyzed by the Institute for the Study of War, a Washington-based think tank.

Mr. Barabash said Russian forces were trying to encircle Avdiivka, which sit in a strategic pocket surrounded to the north, east and south by Russian positions.

He reported intense fighting to the north and south of the town, adding that one civilian had been killed and several others wounded over the past day.

But encircling Avdiivka would most likely require more forces than Russia has committed to its offensive in the area so far, according to the Institute for the Study of War.

Over time, Avdiivka has become a symbol of resistance to Russia’s onslaught. It withstood eight years of low-intensity warfare in eastern Ukraine before the invasion began in February 2022, and now a year and a half of enormous assaults by the Russian Army, which have left the town in ruins and forced almost all of its 30,000 inhabitants to flee.

Ukrainian forces have held out through airstrikes and continual artillery bombardment, using the grounds of a coking coal factory as a fortress and digging trenches and bunkers around the area.

“Avdiivka. We are holding our ground,” President Volodymyr Zelensky of Ukraine wrote on the Telegram messaging app on Thursday.