Clashes in China's restive Xinjiang region have left 21 people dead, including 15 police officers and officials, authorities say.
The violence occurred on Tuesday afternoon in Bachu county, Kashgar prefecture.
The foreign ministry said it had been a planned attack by a "violent terrorist group", but ethnic groups questioned this.
There have been sporadic clashes in Xinjiang in recent years.
The incidents come amid rumbling ethnic tensions between the Muslim Uighur and Han Chinese communities. In 2009 almost 200 people - mostly Han Chinese - were killed after deadly rioting erupted.
It is very difficult to verify reports from Xinjiang, reports the BBC's Celia Hatton.
Foreign journalists are allowed to travel to the region but frequently face intimidation and harassment when attempting to verify news of ethnic rioting or organised violence against government authorities.
Hou Hanmin, director of the Xinjiang government's propaganda department, said Tuesday's clashes began as officials described as community workers searched homes for weapons.
She told the BBC's Chinese service that three of the workers were killed as they were investigating reports of suspicious individuals at the home of a local resident.
Unarmed police then arrived to investigate the workers' earlier reports and were attacked, said Ms Hou. Three "thugs" died and nine police officers were cornered in a house which was then set on fire, she said, calling the incident a "planned terrorist attack" on innocent victims.
There was no information on the identity of the assailants. Ten of the officials and police killed were ethnic Uighurs, the local authorities said.
Eight people were arrested.
Foreign ministry spokeswoman Hua Chunying said initial police investigations showed it had been "a premeditated attack carried out by a violent terrorist group".
She said the security situation in Xinjiang was "good in general, but a small cluster of terrorist forces are still doing their very best to upset and sabotage Xinjiang's stability and development".
"I believe their plan goes against the will of the people and is doomed to fail," she told a news conference.
But Dilxat Raxit, a spokesperson for the World Uighur Congress, an umbrella organisation of Uighur groups, told the BBC the incident was caused by the killing of a young Uighur by Chinese "armed personnel" as a result of a government clean-up campaign.
Uighurs make up about 45% of the region's population, but say an influx of Han Chinese residents has marginalised their traditional culture.
Beijing authorities often blame violent incidents in Xinjiang on Uighur extremists seeking autonomy for the region. Uighur activists, meanwhile, accuse Beijing of over-exaggerating the threat to justify heavy-handed rule.
In March, 20 people were jailed on terrorism and separatism charges in the region. Last August courts jailed another 20 people on similar charges in Xinjiang.