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.