State media reported that city officials ordered all residents to stay home unless they had a pressing reason to go out and suspended all transport to and from the city apart from special cases.
The order was to take effect at midnight and last indefinitely.
One person from each household will be permitted out every two days to buy household necessities, the order said.
Xi’an on Wednesday reported 52 new locally transmitted cases of the coronavirus over the previous 24 hours.
China has adopted strict pandemic control measures under its zero-transmission program, leading to frequent lockdowns, universal masking and mass testing.
Those measures have been stepped up in recent days ahead of the start of the Beijing Winter Olympic Games on Feb. 4.
The Xi'an restrictions are some of the harshest since China in 2020 imposed a strict lockdown on more than 11 million people in and around the central city of Wuhan after COVID-19 was first detected there in late 2019.