The Id Kah Mosque in the city of Kashgar, in far-western China, is a peaceful and homely place, constructed from wood and with its prayer hall supported by tree-trunk pillars. Poplars dapple the courtyard with shadow; rose bushes line the pathways. It was built in 1442, and for the past five and a half centuries Muslims have been coming here to pray.
In 1949, China annexed Xinjiang, of which Kashgar is the cultural and religious capital, pre-empting a push for independence by the Uighurs, the region's Turkic-speaking Sunni Muslim majority. Like neighbouring Tibet, Xinjiang was ruled by China at various points in its history. For Beijing, there was imperial and defensive logic in owning this vast tract of land where mountains alternate with desert. It acted as a buffer between China and the west, and it had oil. And the sparsely populated deserts would later prove useful for conducting nuclear tests.
During the Cultural Revolution, China cracked down on Islam in Xinjiang, just as it had clamped down harshly on Buddhism in Tibet. By the late 1970s, however, this policy was deemed a failure and the emphasis shifted to merging China's various religions and cultures in one large melting pot. Today, if you visit the Id Kah, you will find state policy displayed in broken English on a signboard: "All ethnic groups live friendly together here. They co-operate to build a beautiful homeland . . . and oppose ethnic separation and illegal religious activities."
Unsurprisingly, given the level of interference by the state, many Uighurs see the Chinese as invaders who threaten their culture and religion. While Beijing remains intent on importing Han people and commerce to Xinjiang, in the streets north of the mosque there is still quiet resistance. Here, where old men play chess in ornately painted teahouses and stallholders sell a teeth-cracking sweet made from crushed walnuts, it is common to meet old women who speak no Mandarin, artisans who consider China a foreign land, and traders who refuse to follow Beijing time (enforced throughout China, so that offices open at 9am, which is 7am to local people).
But Kashgar is in quiet turmoil over Beijing's attempts to change it. In 2003, the crowded bazaar south of the mosque was cleared, a huge open square was built, and a gigantic television screen was placed in the centre, blasting out soap operas and football matches to the Uighurs who come here for prayers.
"Even the tiles were changed to confuse us Muslims," a shopkeeper told me. (The old tiles pointed towards Mecca; the new ones are of an abstract, wavy design.) "The Han settlers should return to China," he said, and added in a brutal whisper: "We are being overtaken by money-grubbers with slitty eyes and yellow skin."
Later, in the privacy of his house, the shopkeeper was even more explicit. "Who are these so-called terrorists?" he said. "Isn't the battle in Chechnya a freedom fight? Isn't it so in Kashmir? In Kashgar?" He continued, wearily: "I fear for my children's future. What opportunities do they have? Very few Uighurs are given passports. We have no politicians in Beijing. The schools teach nothing of our local culture. Uighur children are ignorant about traditional music, desert animals, our historic writers. Religious education is entirely lacking."
In Xinjiang it is extraordinary to hear such views expressed, especially in public. Since 1949, according to Amnesty International, thousands of Uighurs seen to be sympathetic to the cause of independence have been arrested and jailed. With the Bush administration's war on terror and the security paranoia of the Beijing Olympics, repression has taken on an unusually international flavour: "separatists" are now called "terrorists", and links are drawn to al-Qaeda.
Tellingly for a country that boasts new freedoms of religion, it is against the law in Xinjiang to impart religious knowledge to a person under the age of 18. Many Uighurs fear incriminating themselves by teaching the precepts of Islam to their children and, in consequence, religious instruction begins very late.
Years of state control have left many Uighurs feeling ashamed. They know that their co-religionists elsewhere (particularly in neighbouring Pakistan) consider them to be Muslims in name only. Inevitably, the behaviour of women comes under particular scrutiny.
When I arrived in Xinjiang from Pakistan, as I did the first time I visited China, I found the contrast arresting. Uighur women ride bicycles and scooters, a liberty unthinkable in Islamabad or Lahore. In Uighur restaurants, women in headscarves get to their feet and dance together between the tables. At the livestock bazaar, old women with gold teeth bargain for goats with bearded farmers. At a musical instrument shop in the centre of town, on my first visit, I listened as a teenage girl took up a rebab, a mulberry-wood lute lined with snakeskin, and played a Uighur folk song about unrequited love.
Unlike in Pakistan, all children in Xinjiang go to co-ed schools, and school attendance is enforced. Uighur women who desire to earn a living are encouraged by the state (if not by their more conservative husbands). "I took a medical degree," said Zaynab, a doctor I met. "Now I have a job working with heroin addicts. I am very busy." Perhaps the finest legacy of communism in China is gender equality.
Many Uighur men, however, complain that their women are forbidden from wearing headscarves to school or in government jobs. "Only very old women are allowed to cover themselves properly," a Uighur housewife told me. Discouraged at any time from dressing in Islamic cloaks or coats, almost all Uighur women wear knee-length skirts and transparent black tights. At first glance, they appear to be conforming to the Chinese dress code, but beneath the tights are pale leggings that shield every inch of skin from sight. "So our women look Chinese," a taxi driver explained to me, "without behaving like them."
This negotiation of two conflicting cultures is familiar in a country that distinguishes, often arbitrarily, between "normal" and "illegal" religious practice: headscarves not burqas, mosques not madrasas, state-vetted imams not dead Sufi saints. A little religious observance - but nothing too fervent.
At Kashgar's international bus station, I bought a ticket for the two-day ride to Pakistan. As the bus filled up with travellers, I noticed an old man in a skullcap who climbed aboard with two silver-haired women. These three elderly people were going for umrah, the pilgrimage to Mecca that all pious Muslims try to perform at least once in their lives. Their entire family had come to see them off; it was an emotional moment, and the women were in tears.
The next morning, at the immigration office, a young Chinese soldier stamped my passport without even checking my luggage. The three pilgrims, however, were taken aside for questioning as soldiers rifled slowly through their bags. They had already paid for the plane tickets on from Pakistan, and their passports were embossed - as another Uighur later told me - with "all the correct visas". Outside, in the sunshine, we waited for one hour, for two. Eventually, the three old people were led away.
As our bus drove up into the mountains without them, I thought of the signboard at the mosque in Kashgar: "All ethnic groups live friendly together here."
Alice Albinia is the author of "Empires of the Indus: the Story of a River", published by John Murray (£20 hardback)