A billboard at the main entrance to the city of Kupiansk illustrates the tenuous nature of Ukrainian control in a region that has become one of the most active parts of the 750-mile front line in the war.

“Kupiansk is Ukraine!!!” it proclaims to anyone entering the city. The other side of the sign, visible to those in the city center, hints at why the first proclamation is so urgent. It shows an armed soldier standing in front of a helicopter, along with a phone number and a question: “Do you have information about traitors to Ukraine?”

At the outset of the war, Kupiansk, only 25 miles from the Russian border, fell to Moscow’s forces without a fight and remained under occupation for six months before being retaken in a lightning Ukrainian thrust in the Kharkiv region in the country’s northeast in September.

Now, however, while most attention is focused on the Ukrainian counteroffensive hundreds of miles to the south, Russian forces are mounting an offensive in the north, seeking to regain those lands. Kupiansk, a strategically important city that served as a logistical center for the Russian military, is right in the cross hairs, and many residents say they dread the return of the forces who terrorized them for six months.

The situation has worsened to the extent that the regional authorities announced on Thursday the mandatory evacuation of people living in the district.

“No one can survive a second occupation,” said Liudmila Sezonova, who runs a honey wholesale business and said she stayed home for months throughout the occupation, hoping that she would not be penalized by the Russians for being a Ukrainian patriot.

During those months, “you could keep your head down and be quiet,” she said. “But now it is clear who is who and where their loyalties lie.”

From her garden patio, where she and her family had to cook on a makeshift stove when there was no electricity, gas or running water during the occupation, the thuds and booms of the war were ever-present.

Her son Albert, 5, never flinches, or even looks up from the shooting game he is playing on his mother’s phone.

They chose to stay despite the heavy bombardment that came after the Russian withdrawal and destroyed much of the city center, and are weathering an intense period of fighting on the city’s outskirts as Russian forces push to retake the area — or at least try to force Ukraine to divert some forces from the counteroffensive farther south.

“We want to raise Kupiansk back up,” said Ms. Sezonova, 38. “If not us, then who?”

But now the fighting is less than five miles from the city, and soldiers defending a growing maze of trenches to its north said the pace of the Russian artillery attacks had increased significantly in recent days. Though she is not evacuating yet, Ms. Sezonova has packed bags for herself and her family, just in case.

“The hottest direction remains Kupiansk,” Ukraine’s deputy defense minister, Hanna Malyar, said on Monday.

The Russian Army, Ms. Malyar said, “wants to retake the territories in the Kharkiv region that were lost,” she said.

For Ms. Sezonova and others who support the Ukrainian war effort and stayed home, the fear of the return of Russian rule is mixed with an abiding distrust and resentment at those accused of collaborating with the occupying powers. Between those who left Kupiansk with the retreating occupiers and those who fear the near-constant shelling, only about a fifth of the district’s prewar population of 60,000 remains, according to Andriy Besedin, the mayor.

Its former mayor, Gennadii Matsegora, was accused of helping the Russians. A local prosecutor, Eduard Myrhorodskyi, said that once the Ukrainian authorities reasserted control, they found nine torture rooms where they said Russian forces had held local officials who refused to collaborate or people they simply suspected of being pro-Ukrainian.

Some in the new administration say they regard with deep suspicion those who stayed during the occupation, believing they harbor Russian sympathies and could act as saboteurs.

“We don’t trust anyone in the city,” said one local police officer who commutes daily from Kharkiv, a two-hour drive. He noted the city’s proximity to the border and the uptick in intense fighting.

“No one in the administration sleeps in the city,” said the police officer, who spoke on the condition of anonymity for fear of possible retribution, “because they know it is possible they might wake up one morning living under a new flag.”

Between the danger and the mistrust, it has been difficult to re-establish life in the city, said Oleksandr and Tamara Shapoval, both retirees. Utilities like gas, water and electricity have been restored, but “we almost don’t see the authorities,” Ms. Shapoval said.

And with good reason. Mr. Besedin, the mayor, said that out of 189 people working in the administration before the Russians invaded, only 10 of them are still in their jobs. Another 30 have been hired since Ukraine took control.

The Shapovals said they were trying to return a sense of normalcy to their lives, but with an acute awareness of the divided loyalties in their city, it is hard to trust people. Local intelligence operatives told them that at least three of their neighbors had denounced them to the Russians.

“We lived close to each other, helped each other and then it turned out that they actually wanted to live in Russia,” said Ms. Shapoval, 62, who like many others living in Kupiansk has close relatives in Russia but is ardently pro-Ukrainian. “It’s like escaping from a lion by going directly into the lion’s mouth.”

She said while she believed that most of the Kremlin’s most public cheerleaders had already left, “there are lots of people who are waiting for Russia to come back.”

On a recent morning, merchants brought their wares to a makeshift market near the city’s sports stadium. Despite the extreme heat, butchers laid out raw meat on the hoods of their cars, whacking away flies with branches or fly swatters jury-rigged with plastic bags.

There were no refrigerators for the meat and dairy products, because shelling had destroyed the city’s public market. And a lot of people who sold their goods there had left for Russia anyway, Ms. Shapoval said.

“We wish for the war to end as soon as possible, but I don’t think it will happen so fast,” said Olena Bohachova, 69, who was selling homemade sour cream and whey with her daughter.

“I am not sure our soldiers would be able to push them back that quickly,” Ms. Bohachova said as explosions boomed in the distance.

Ms. Bohachova, who is originally from Crimea, the Ukrainian peninsula that Russia illegally annexed in 2014, said that she had argued with her brother, who she said sometimes parroted the false Kremlin line that Russian soldiers had come to liberate Ukraine from the Nazis.

“I told him: ‘You know, I have never seen any Nazi in my life. I don’t know who they are. Maybe they are somewhere, but I have never met any. Here there are just normal people.’”

While the ordinary citizens who remain say they have grown accustomed to the shelling, most of them are ready to flee at a moment’s notice.

“The front line is close, and it is dangerous,” Ms. Sezonova said, “but we’ve realized that in Ukraine nowhere is completely safe anyway.”

Dzvinka Pinchuk and Evelina Riabenko contributed reporting.