The Chinese city of Xi’an on Wednesday ordered its 13 million residents to stay at home and avoid unnecessary outings in one of the biggest lockdowns related to the pandemic in the country this year.

Since Dec. 9, the city in the northwest of China has confirmed more than 140 Covid-19 cases, city officials said at a briefing.

Of 57 cases reported...

The Chinese city of Xi’an on Wednesday ordered its 13 million residents to stay at home and avoid unnecessary outings in one of the biggest lockdowns related to the pandemic in the country this year.

Since Dec. 9, the city in the northwest of China has confirmed more than 140 Covid-19 cases, city officials said at a briefing.

Of 57 cases reported nationwide for Tuesday, 52 were in Xi’an, according to the National Health Commission. Many recent Covid-19 cases found in other cities, including Beijing and Dongguan, were travelers from Xi’an.

Officials in Xi’an said infections reported there were with the Delta variant of the virus.

Late Wednesday, the Xi’an city government said on its verified social-media account that another 127 people in the city had tested positive for Covid-19 in an additional round of mass testing. It didn’t say what variant caused the new infections.

The Omicron variant so far hasn’t wreaked havoc in China, though several Chinese cities have reported Omicron cases among international travelers and at least one locally transmitted infection, according to state media.

Still, Omicron’s quick spread outside China could present one of the most complicated possible Covid-19 scenarios for the 2022 Winter Olympics in February, which is scheduled to bring thousands of athletes from dozens of countries to Beijing. In response to questions about how to control the spread of Covid-19, International Olympic Committee and Beijing organizers have cited the latest update of virus protocols, which were crafted before the emergence of the highly contagious Omicron variant.

Zhangjiakou, a city of about four million where one of the three Olympic villages is located, conducted a two-day drill this week, including emergency-response measures such as mass testing, according to a statement Wednesday on the website of the Beijing Organizing Committee.

Vaccine and medicine producers and research institutes in China are racing to study the Omicron variant. Nearly 78% of the Chinese population was fully vaccinated as of late November, according to government data, though Chinese health experts have said little about how well China’s vaccines work against new variants of the virus.

Initial clinical trials for Chinese vaccines showed their efficacy levels to be generally lower than mRNA vaccines such as those developed by Pfizer Inc. and Moderna Inc.

Xi’an residents lined up for Covid-19 tests on Tuesday.

Photo: Li Yibo/Zuma Press

Since closing off the city of Wuhan, the original center of Covid-19 spread in early 2020, China has continued to use lockdowns along with mass testing and mandatory quarantine to battle the virus anywhere it might flare up. The Xi’an lockdown was unusual in that it encompassed the entire city, not just certain districts.

After Xi’an officials announced the stay-at-home order Wednesday afternoon, local residents rushed to grocery stores to stock up on food. The city, known for its terra-cotta warriors, allows one family member to do grocery runs every two days.

Hu Tao, a resident of the city’s Beilin district, said the lockdown isn’t as bad as one last year when nobody except essential workers could go out. He didn’t rush to buy groceries as he considered it not safe. He and his wife have been shopping online for things such as diapers for his 1-year-old son.

“We are staying put again,” Mr. Hu said. “It’s almost the new normal now.”

A growing number of studies indicate Omicron is more resistant to current vaccines than previous Covid variants, though boosters seem to help. WSJ’s Daniela Hernandez gets an exclusive look inside a lab testing how antibodies interact with Omicron. Photo illustration: Tom Grillo The Wall Street Journal Interactive Edition

High schools and universities in the city have moved classes online and child-care centers are closed for the year. All indoor dining and outdoor gatherings, such as group dancing in public spaces, have been suspended.

Many college students in Xi’an, which is home to dozens of universities, resorted to social media to vent about the lockdown, with some worrying that the lockdown will prevent them from taking upcoming graduate-school entrance exams.

Officials urged residents not to leave town unless they are tested for Covid-19 and have clearance from employers or community-level authorities.

Some local governments in the Yangtze River Delta and Manzhouli, a city bordering Russia, that had previously announced lockdown measures, this week started gradually resuming production and allowing certain travel.

Write to Liyan Qi at liyan.qi@wsj.com