BAGHDAD, Feb. 24 -- During what turned out to be the last Friday prayer he led, Imam Mohammad al-Marawi urged worshipers at a Sunni mosque in the western city of Habbaniyah to stand firmly against al-Qaeda in Iraq, a Sunni insurgent group that has a strong following in the area.

"A bunch of corrupted individuals," the imam called the group's members, according to a man who was at the service.

Less than 24 hours later, someone in a Mercedes truck drove up next to the mosque and detonated explosives hidden under a load of stone and marble. At least 40 people were killed, including 15 who were praying inside.

The blast Saturday afternoon in front of Hay al-Ummal mosque killed several passersby, including women and children. The mosque is within a few feet of a children's clinic and a police station.

"If the target was the police station, the truck would have been placed near it, not next to the mosque's outer wall," said Hussein Ali, a prominent community leader.

The bombing was the first in recent months to kill dozens of civilians in a predominantly Sunni area. But witnesses said that unlike other large attacks, this one did not appear to have been driven by sectarian rivalries -- Shiite militias are not known to be active in the area -- but rather was probably carried out as a warning from Sunni extremists to Sunnis who support the U.S.-backed Iraqi government.

Tribal leaders in Habbaniyah and other Sunni insurgent strongholds in volatile Anbar province have tried to mobilize civilians against al-Qaeda in Iraq, which has sought to impose strict Islamic code in several regions and has frequently attacked U.S. and Iraqi forces.

Falah al-Dulaimi, leader of Anbar Civil Defense, one of several groups trying to quell the insurgency, said in a telephone interview that insurgents had nicknamed the city "Tel Aviv," a disparaging reference to U.S. influence.

Despite warnings from Sunni insurgents, women in Habbaniyah are not forced to cover their hair with the traditional hijab, and residents are free to use the Internet and cellphones.

U.S. soldiers stationed at a nearby facility responded to the blast in Habbaniyah, which is about 50 miles west of Baghdad. They cordoned off the area and transported many of the wounded to medical centers.

Alaa Jaber al-Marawi, 30, who owns a grocery store across the street from the mosque, said the bombers probably picked the site because it is on the edge of the city's well-guarded center. He said in a phone interview that his brother was among the injured and that one of his legs was amputated Saturday night.

The attack came as thousands of troops from across the country are being deployed to the capital for the implementation of the Baghdad security plan. Some provincial leaders are concerned that the new measures in Baghdad might push insurgents and militias to other parts of the country.

Also Saturday, Iraqi President Jalal Talabani issued a statement calling for the punishment of U.S. soldiers involved in the temporary detention of the son of an influential Shiite political leader.

Amar al-Hakim -- whose father, Abdul Aziz al-Hakim, heads the Supreme Council for the Islamic Revolution in Iraq -- was detained Friday near the southern city of Kut after returning from Iran.

Talabani said Hakim had "received uncivil and inappropriate treatment" during his hours-long detention. U.S. officials said soldiers had not singled him out, and they described his detention as a routine procedure along the heavily patrolled border.

Special correspondent K.I. Ibrahim contributed to this report.