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.

Analysis Nothing is stopping foreign journalists from booking flights to Xinjiang after hearing reports of violence there. However, simply travelling to the region doesn't guarantee the ability to dig out the truth behind this story. In 2009, dozens of foreign reporters were permitted to join an official tour of Urumqi, the capital of Xinjiang, after clashes between minority ethnic Uighur residents and majority Chinese Hans killed 197 people. Their experiences were mixed. Some reporters were able to speak to a variety of people on the ground, while others faced harassment and intimidation. The situation remains the same today. Reporters who travel to the area are closely followed by government minders. Locals often hesitate to answer questions, fearing reprisals from government authorities. Uighur exile groups often provide accounts that differ from the official Chinese government reports. Reconciling the two can be tricky. The situation isn't any easier for Chinese journalists. China's propaganda departments have warned domestic news outlets against conducting their own independent reporting on sensitive Xinjiang stories, ordering them to reprint official stories from China's major state news agencies.

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.

'Terrorism'

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 and Xinjiang Uighurs are ethnically Turkic Muslims

They make up about 45% of the region's population; 40% are Han Chinese

China re-established control in 1949 after crushing short-lived state of East Turkestan

Since then, large-scale immigration of Han Chinese

Uighurs fear erosion of traditional culture

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.