PATTANI, Thailand -- A heap of bodies in a bullet-scarred mosque attested to a sharp and sudden upsurge of separatist violence Wednesday in Thailand's Muslim south. While the prime minister said the issues were strictly local, some tied the clashes to the country's support for the war in Iraq. Police said they shot and killed 107 Islamic fighters -- including 32 inside the mosque -- after repelling near simultaneous attacks by hundreds of militants. The violence began when the militants, mostly teenagers, stormed about 15 police stations and government buildings in three provinces. Most of the attackers were armed only with machetes, but at least some of those killed in the mosque had guns. Three policemen and two soldiers were killed and 17 militants arrested during the pre-dawn attacks.
Prime Minister Thaksin Shinawatra said authorities had been tipped off and were ready for the attacks. He said the outcome would help end an Islamic insurgency that has simmered for decades in this Buddhist nation's impoverished south.
"It will be hard for them to do these kind of bad things again," Thaksin told reporters in Bangkok, the capital.
Muslims, 5 percent of Thailand's 64 million people, are a majority in the country's thin southern peninsula. They have long complained of cultural, religious and economic repression by the central government, some 600 miles away in Bangkok.
Thaksin blamed a surge in violence this year on money flowing into the south from drug traffickers and corrupt politicians. Other officials say the trouble stems from rival criminal factions or conflicts between corrupt army and police forces over the spoils of smuggling.
Thaksin insisted no foreign terrorists were involved, though the area is believed to have been used as a hiding place for militants linked to al-Qaida through Jemaah Islamiyah, a regional terrorist group.
Mansalan Mohamad, a lecturer at the Yala Islamic College in the south, acknowledged the motives cited by the prime minister but said they weren't the whole story. "The trend of growing Muslim anger and the war in Iraq, the situation in the Middle East, also are part of the factors," he said.
Thailand has about 450 troops in Iraq and has cooperated closely in efforts to catch terrorists in Southeast Asia.
Analysts said Wednesday's attacks may indicate rising stakes in a hitherto small-scale battle of bombings and drive-by shootings.
Sunai Phasuk, a Bangkok political analyst, said the attackers showed readiness to fight and die. "They fought with knives and swords, fully understanding that the police will be ready and waiting for them with M-16 rifles ... they refused to back off."
"This is very dangerous," he said.
Thaksin said the attackers arrived at their targets on brand new motorcycles. "This proves they got financial support from influential figures, including politicians and drug gangsters," he said, without elaborating.
The prime minister said the assailants' apparent goal was to steal guns, as they did in a Jan. 4 attack on a military base that netted hundreds of weapons.
But security forces lying in wait responded with a hail of bullets Wednesday. TV footage showed attackers' bodies sprawled in pools of blood, some of them still clasping machetes.
Chayasith, the army chief, said one group of 32 attackers fled the initial skirmishes to the 16th-century Kreu-Se mosque in Pattani, a town of a few thousand people.
"They were well trained," he said. "Those who were holed up in the mosque for hours had M-16 and AK-47 rifles and were skilled in using such war weapons."
Security forces lobbed tear gas canisters into the flat-roofed single-story shrine before peppering it with grenade and automatic fire.
By the time journalists were allowed in, no guns were in evidence. Police said they had collected them.
Waedaloh Hayeesohoh, a Muslim elder from a nearby village, said he heard gunfire and went to investigate. "I saw some men and knew they weren't from around here. They were armed with guns and knives," he said.
After authorities left, villagers rushed into the mosque. They picked up bullet shells and came out sneezing from tear gas.
A man emerged from the mosque waving soiled pages of the Muslim holy book and shouting "Blood on the Quran! Blood on the Quran!" The crowd watched impassively.
People were clearly in shock. Sarihah Latheh, a 17-year-old Muslim who left home in her pajamas at 5 a.m. to watch the fighting, said: "I am angry at the insurgents. They came and shot up a storm in our mosque."
The day's death toll was the worst in the kingdom's modern history, if compared with official counts of 71, 41 and 40 in three military crackdowns on pro-democracy uprisings. Many believe those figures are understated.