Every two days at the University of Xi’an in China, cleaners dressed in white hazmat suits taped tight to their bodies disinfect the dormitory hallways. Zhang Shengzi, a 24-year-old student, said the smell is so pungent she has to wait some time after they’ve gone before she will open her door again.

She can barely leave her room, let alone campus, and all her classes are online.

Ms. Zhang’s university, like the rest of Xi’an, has been under a citywide lockdown since Dec. 22. It is the longest lockdown in China since the first one in Wuhan, where the coronavirus outbreak began almost two years ago.

In scenes recalling the early days of the pandemic, hungry residents have traded coffee for eggs and cigarettes for instant noodles. A pregnant woman and an 8-year-old boy suffering from leukemia are among those who have been denied medical care. People in need of lifesaving medications have struggled to obtain them.

China’s ability to control the virus has come a long way since the pandemic started: It has inoculated nearly 1.2 billion people and set up a nationwide electronic health database for contact tracing.

Yet it has continued to rely on the same authoritarian virus-fighting methods from early 2020, including strict quarantines, border closings and lockdowns. These have led to food and medical shortages and growing questions about how much longer its zero-Covid strategy, the last in the world, can continue.

Despite the frustration, the authorities in Xi’an on Wednesday declared the city’s battle with the virus a victory. Fourteen days into the lockdown, city officials said that Xi’an had achieved “zero Covid on a societal level,” though its 13 million residents remained unable to leave home.

“The district security guards are like prison guards and we are like prisoners,” said Tom Zhao, a Xi’an resident. Mr. Zhao, 38, said he had joined dozens of chat groups last week searching for anyone who could help him find medicine for his mother, who has early-stage diabetes.

Even big multinational companies in the city have been affected. Two of the world’s largest memory chip makers, Samsung and Micron, said they have had to adjust operations at their manufacturing bases in Xi’an because of the restrictions, potentially roiling the already fragile global supply chain.

Xi’an has reported 1,800 cases in its latest outbreak, stunningly low compared with the daily case count in the United States. And as the world struggles to contain the spread of Omicron, in China officials have reported only a few local cases of the variant, and none in Xi’an.

The authorities are nevertheless worried, in a country that has stridently stuck by its zero-Covid policy — and held up its success fighting the virus as proof that its authoritarian style of leadership saves lives.

The Beijing Winter Olympics and the Lunar New Year holiday are a few weeks away, and China’s vaccines appear to be less effective than their Western competitors, particularly against variants. The country has yet to approve mRNA technology for its vaccines, and while booster shots are now widely available, their takeup in the country has been slower than the initial jabs.

“The Xi’an epidemic is the most serious after Wuhan was shut down,” said Zeng Guang, a Chinese epidemiologist who visited Wuhan in the early days of the pandemic and was quoted in state media on Wednesday. “People across the country should give Xi’an a lot of support, hoping that Xi’an will accumulate new experience in epidemic prevention.”

So far, the experiences have been grim. Tens of thousands of people have been relocated to centralized quarantine facilities to stop the spread. Several top city officials have been fired, and the head of Xian’s big data bureau was suspended.