BEIJING—Chinese police "gunned down" several rioters after four people were killed in an attack on a police station in the northwestern region of Xinjiang, the state media reported, in what appeared to one of the most violent incidents in the mostly Muslim area since it was shaken by ethnic rioting in 2009.

Two security personnel and two hostages were killed, and one other security officer was injured in the attack, which began around midday Monday in Hotan, a small, remote oasis city on the edge of the Taklamakan desert, the state-run Xinhua news agency said. The agency gave no details of how many attackers were killed or injured.

Armed police rescued six other hostages and regained control of the situation by around 1:30 p.m. local time, Xinhua said. It added that China's National Counter-Terrorism Office had taken charge of the operation in the city, which is not far from the border with Pakistan and has a population of about 115,000.

Xinjiang is home to the predominantly Muslim and Turkic-speaking Uighur ethnic minority, many members of which complain that China's government has plundered the oil-rich region's resources, swamped it with ethnic Han Chinese migrants, and restricted religious freedom.

China denies those charges and has for decades battled Uighur groups waging a sporadic and sometimes violent struggle for independence. Beijing sees such groups as part of a terrorist organization with links to al Qaeda, and has sought international support for its campaign against them.