Image copyright AP Image caption There are differing accounts of what sparked the violence

Two men have been sentenced to death and three more jailed over a clash in China's far-west Xinjiang region that left 21 people dead.

The incident happened on 23 April in a town in Kashgar prefecture. Fifteen officials or security personnel were among those killed.

China said it was a planned attack by a "violent terrorist group".

But other accounts dispute this, attributing the confrontation to ethnic tensions in the restive region.

Xinjiang is home to the Muslim Uighur minority, who make up about 45% of the region's population but say an influx of Han Chinese residents has marginalised their traditional culture.

The authorities often blame violent incidents in Xinjiang on Uighur extremists seeking autonomy for the region.

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

Uighur activists, meanwhile, accuse Beijing of over-exaggerating the threat to justify heavy-handed rule.

Verifying reports from Xinjiang is difficult.

While foreign journalists are allowed to travel to the region, they frequently face intimidation and harassment when attempting to verify news of ethnic rioting or organised violence against government authorities.

The BBC team that visited the site of the incident to try to clarify details were taken by police to a government compound and subsequently ordered to leave.

'Religious extremism'

The two men sentenced to death by Kashgar's Intermediate People's Court on murder and terrorism charges were named in state media as Musa Hesen, the co-founder of the "terrorist group", and Rehman Hupur.

It is not clear how the dispute turned so violent and why so many police and officials were killed, but a third person said: 'I think the government bothered them too many times. They became very annoyed.' (from April 2013) Doubts over attack claims

Three other men were jailed for terms ranging from nine years to life.

The group had been "carrying out illegal religious activities (and) promoting religious extremism", Xinhua news agency reported, citing a court statement. They had also "made 10 explosive devices and carried out explosive tests", it said.

The violence was sparked when three officials saw suspicious behaviour at a house, Chinese reports say.

Residents seized the officials and several more police who came to the scene, many of whom burned to death when the house was set on fire. Security personnel shot six suspects, Chinese reports say.

Media playback is unsupported on your device Media caption April 2013: Damian Grammaticas visits the violence-hit town

But a group of local people in Selibuya town, where the clashes happened, told the BBC that the violence involved a local family who had a long-standing dispute with officials who wanted the men to shave their beards and the women to stop wearing full veils.

A spokesperson for the World Uighur Congress, an umbrella organisation of Uighur groups, also disputed the government's version, saying the clashes were a result of a government clean-up campaign.

The incident comes amid rumbling ethnic tensions between the Muslim Uighur and Han Chinese communities.

In 2009 almost 200 people - mostly Han Chinese - were killed in deadly rioting in Xinjiang's capital, Urumqi.

There have been sporadic eruptions of violence since then - in June 2013, 35 people were killed in rioting in the township of Lukqun, about 200km (120 miles) south-east of Urumqi.