That afternoon, we walked inside the 15th-century Id Kah Mosque, where young men stabbed to death the imam in 2014. We passed through metal detectors. In the courtyard, I noticed surveillance cameras above paths. The same cameras were present throughout the old city.

In the plaza in front of the mosque, I saw a mobile police station and officers milling around. One officer walked up to Abdul Wahid and asked him for his papers. Abdul Wahid said he was taking us foreigners around. The policeman then turned and walked over to a long line of Uighur men whom he had rounded up. He led them away to register them.

What I saw was happening across Xinjiang. In late 2016, regional officials established thousands of mobile police stations and deployed tens of thousands of policemen to staff them, according to an article last December in Foreign Affairs by two scholars, James Leibold and Adrian Zenz. The Xinjiang party chief, Chen Quanguo, was putting in place the same grid policing system he had used in Tibet.

Back at the hotel, I said goodbye to our guide. An American diplomat I had met in Beijing was checking in.

In the evening, we took a final stroll. We stopped at a carpet shop owned by the father of Abdul Wahab, a young Uighur man who visited Beijing to sell carpets and whom I knew. He had just been in eastern China and was on his way back to Kashgar to get married, but his flight had been grounded in Urumqi because of fog. We would not see him on this trip.

As Abdul Wahab’s father, Ahmad, showed us carpets, Mr. Yusuf walked into the room. A couple of police tails lingered outside. Ahmad spread out a few carpets. Some had the classic pomegranate design native to Xinjiang. I began negotiating for one.

“I think that’s a good one,” Mr. Yusuf said, pointing to the piece that had caught my eye. But he shook his head at the price.

Mr. Yusuf and his colleagues trailed us when we left. We went into a restaurant to have a kebab dinner. They did not follow us inside, and we saw no sign of them for the rest of the night.