Attackers hurled explosives and opened fire on an Islamic school in southern Thailand, killing three students and sparking a riot by angry Muslim villagers, officials said Sunday.

Shortly after the attack, three Buddhists were shot dead in the same district, raising fears that a festering insurgency that has already taken more than 2,000 lives could erupt into open combat between the Muslim and Buddhist communities.

Attackers hurled explosives and sprayed dozens of bullets into a dormitory of the Bamrungsart Pondok boarding school, where about 75 boys were sleeping, killing a 12-year-old and two 14-year-olds, police Col. Thammasak Wasaksiri said.

Seven other teenagers were wounded in the attack in the Sabayoi district of Songkhla province, he said.

An estimated 500 protesters gathered outside the school, carrying the dead children's bodies through the crowd and setting fire to two buildings at a nearby government-owned school. Some hurled stones at police.

After the school attack, suspected Muslim insurgents stormed a nearby charcoal factory, killing two Buddhist workers and wounding at least two others. Separately, a Buddhist man riding a motorcycle was gunned down.

Thammasak said police believe Muslim insurgents staged the school attack in an attempt to convince villagers that authorities were responsible and win them over to the insurgents' cause. Villagers, however, refused to believe Muslims were behind the violence and blamed government security forces, he said.

Thai authorities also blamed insurgents for a bombing at a mosque and a grenade attack at a tea shop last Wednesday that killed two Muslims in neighboring Yala province. Those attacks came hours after suspected Muslim insurgents killed eight Buddhist passengers in a commuter van in the same district of Yala, shooting them in the head execution-style.

Thailand is overwhelmingly Buddhist, but the country's far south is predominantly Muslim, and residents of the region have long felt that they are treated like second-class citizens.

The southern Muslim provinces have hundreds of religious Islamic schools, and authorities have accused some of them of harboring insurgents and serving as a training ground for violence.

Lt. Gen. Wirot Buacharun, the army commander in charge of the restive provinces, said security forces had recently raided an Islamic school and confiscated an M-16 assault rifle, bullets, a computer containing suspicious material and other documents believed to be linked to the insurgency.

"This leads us to believe that religious schools are involved with the ongoing violence," he said Sunday, adding that he would urge the government to revoke subsidies for the schools or close some of them.

Drive-by shootings and bombings occur almost daily in Thailand's three Muslim-majority provinces -- Yala, Narathiwat and Pattani -- and increasingly in the neighboring province of Songkhla.

Though Buddhist teachers have been targeted by the violence that flared three years ago, schoolchildren have largely been spared.

Violence in the south has increased since a military-installed government took power in September following a coup that ousted then-Prime Minister Thaksin Shinawatra.

Thailand's military imposed a curfew in two Yala districts on Thursday. Army spokesman Col. Akara Thiprot said it was the first time a curfew has been imposed in the region since separatist violence surged in January 2004.