KHARKIV, Ukraine – The thuds of artillery start with a low-decibel rumble, but rattle your ribcage as you get closer. A junction at the northern entrance to Kharkiv is about as close to the front lines as anyone would want to be on Friday, as Ukrainian soldiers fought a fierce battle to drive Russian forces away from the city.

The empty carcasses of burnt-out Russian armored personnel carriers and a Ukrainian police jeep littered the road, along with the scattered personal effects of their former occupants – water bottles, a soldier’s boot, camouflage clothing. Nearby, the body of a Russian soldier, dressed in a drab green uniform, lay on the side of the road, dusted with a light dusting of snow that fell overnight.

The position was held, as early as Friday, by a group of lightly armed Ukrainian soldiers who had hastily dug trenches in the wet mud by the side of the road, periodically plunging into them when the artillery boom was particularly loud.

Behind them, huge blue and yellow letters spelled KHARKIV, marking the entrance to Ukraine’s second-largest city, home to 1.5 million people, in the northeastern part of the country.

It was unclear whether the Russian troops in these destroyed armored vehicles had intended to enter the city, as were the intentions of their comrades fighting what looked like a vicious battle just beyond a line of trees in the distance. They had pushed into the area a day earlier, having traveled around 40 miles from their staging area near Belgorod in Russia.

Ukrainian soldiers sent to man the post had few details about the fight that took place there, saying only that it happened on Thursday morning, shortly after Russian President Vladimir V. Putin gave the order to attack.

“Putin wants us to throw away our weapons,” said a Ukrainian soldier named Andrei, from inside a muddy trench. “I think we could operate more sneakily, gather our forces and launch a counterattack.”

Credit…Tyler Hicks/The New York Times

Most of the fighting seemed to take place a few miles from the city limits, near a village called Tsyrkuny.

The number of military and civilian casualties resulting from the fighting was unclear, but on Friday local police said a 14-year-old boy was killed in a village near Kharkiv when a shell landed near his house . But strikes sometimes strike close enough to town to elicit cries of terror from pedestrians, sending them fleeing into subway stations for safety.

At a metro station in central Kharkiv, terrified residents were locked in for two days along with their babies, pets and the few personal belongings – blankets, yoga mats and a change of clothes – they could grab outside. short journeys home and back, during breaks in the shelling. The city parked trains in the station and allowed people to sleep in them.

Lidiya Burlina and her son, Mark, work in Kharkiv and were cut off from their home village, two hours away by train, when the Russians moved in. Since then, they have been living in the metro station. The city’s shops only operate in the morning, Ms. Burlina said, and there is very little bread, the price of which has risen dramatically in the two days since the start of the war. They cannot reach anyone in their village because the local power station has exploded.

“They’re sitting there in the cold, they can’t buy anything and there’s no heating,” Ms Burlina said. “And we are here in the subway.”

Victoria Ustinova, 60, was taking refuge on the subway with her daughter, two grandchildren and a fuzzy chihuahua named Beauty, who was wearing a sweater. The family could have taken refuge in the basement of their building, but from there the detonations of artillery and tank fire were still audible.

Credit…Tyler Hicks/The New York Times

“When it all started it was a total shock, when you don’t know where to run and what to expect from ‘comrade’,” Ms Ustinova said, referring to Mr Putin. “Now we have already settled down. We accepted it and try to continue living. It was worse during World War II.

For her 13-year-old grandson, Danil, the main worry now is the possibility of a third world war.

“If things get totally heated, then Europe will join us, and if they start launching nuclear weapons, then that’s it,” he said.

On the surface, most shops and restaurants were closed and few people walked the streets. One of the few exceptions was Tomi Piippo, a 26-year-old man from the Finnish town of Iisalmi, who said he came to Kharkiv on vacation on Monday and could no longer go out.

“I don’t know how to leave. No planes,” he said.

As Russian officials said their military was trying to avoid civilian areas, the body of a Smerch rocket, which Ukrainian officials said had been fired by Russian forces, was stuck vertically in the middle of the street in front of National Guard headquarters. A few kilometers away, the rear part of the rocket had buried itself in the asphalt in front of an Orthodox church with an onion-shaped dome.

A team of emergency services officers, dressed in bulletproof vests and helmets, tried to extract the tail from the pavement, but encountered difficulty. A team member said the tail and the body were different stages of the rocket, likely jettisoned as the explosive ordnance rushed towards its target near the front lines.

“It’s 200 kilos of metal,” said the emergency officer, pointing to the tail of the rocket. “He could have fallen through a building or hit people.”

Even as the artillery barrage intensified, not everyone was ready to hide. Marching intently toward the source of the artillery barrages on the outskirts of Kharkiv was Roman Balakelyev, dressed in camouflage, a double-barreled shotgun slung over his shoulder.

“I live here, this is my home. I will defend him,” said Mr Balakelyev, who also pulled out a large knife he had strapped behind his back as if to show it. “I don’t think the Russians understand me the way I understand them.”

Soon after, Mr. Balakelyev reached the outskirts of the city, where Ukrainian troops were huddled around the abandoned Russian troop carriers. They watched him pass. No one moved to stop him. A soldier uttered: “Intention of victory.

Mr. Balakelyev, his gaze fixed and his shotgun at the ready, walked down the road towards the roadblocks and a large billboard that read: “Protect the future: UKRAINE-NATO-EUROPE”.