BEIJING — Nearly 100 people were killed in recent clashes in the northwestern province of Xinjiang, China said Sunday, making it the deadliest incident of ethnic unrest in the country since 2009.

After days of secrecy shrouding the violence last week in Shache, the official New China News Agency said that 37 civilians were killed by a gang that ambushed vehicles on the main road of the city, near the border with Tajikistan and Afghanistan. Fifty-nine attackers were shot and killed by police, and 215 were arrested.

Citing a report by Zhang Chunxian, the regional Communist Party secretary, Chinese state media described the attack as “organized and premeditated” and launched by “terrorists both inside and outside China.” They identified the mastermind as Nuramat Sawut, and said he had close ties with the East Turkestan Islamic Movement, a shadowy group that seeks independence for Xinjiang, which is sometimes referred to as East Turkestan.

Shache, also known as Yarkand, is mostly populated by Uighurs, a Turkic ethnic minority.

The New China News Agency said the violence broke out early Monday when a “gang armed with knives and axes attacked a police station and government offices in Elixku township.”

“The gangsters also set roadblocks on the Bachu-Shache Road and stopped vehicles passing by, before slashing passengers indiscriminately and forcing civilians to join them in the terror attack,” the report said.

The official account was corroborated by one resident of Shache, a 35-year-old secretary at an insurance company.

“They attacked cars, trucks and buses. They killed the drivers of the vehicles, smashed and burned them. Police opened fire and shot some, but others ran into the cornfields,” said the woman, who gave only her family name, Ma.

“We’ve been told to stay in our homes and not go out much for the next few days.”

Uighur sources said they believe the attack was started by members of two families who had sons who had been sentenced to death for previous incidents. Once the shooting started, other Uighurs joined in, those sources said.

“I believe it is possible that the Chinese overused their firepower. To make sure the incident is reported correctly, I hope the Chinese government will allow international journalists into the area to interview witnesses and make sure that the safety of Uighur witnesses is guaranteed afterward,” Dilax Raxit, a spokesman for the World Uyghur Congress, said earlier in the week.