BAGHDAD — A suicide bomber blew himself up in front of a Shiite mosque in northern Iraq as worshippers left prayers at midday on Friday, killing two civilians and wounding 15.

The attacker set off the blast outside a gate to the mosque in Sinjar, a town in Nineveh province about 85 miles (140 kilometers) west of Mosul, said police chief Col. Awad Kahlil.

Two of the 15 wounded were in critical condition, according to Sinjar's district commissioner, Dakhil Qassim.

Security in Iraq has improved dramatically in past months, though Sunni insurgents remain active around the northern city of Mosul after suffering setbacks in urban strongholds elsewhere in the country. Mosul is an ethnically mixed city on the Tigris River near the country's autonomous Kurdish region.

Also Friday, Shiite followers of anti-U.S. cleric Muqtada al-Sadr demonstrated in Baghdad and the southern city of Kufa against plans for a U.S.-Iraqi security agreement that will determine the status of the U.S. military in Iraq after the current U.N. mandate expires at the end of the year.

In Baghdad's Sadr City neighborhood, Sheik Abdul Hadi al-Mohammadawi, an al-Sadr aide, told worshippers during prayers that it is a "suspicious agreement" that would bring "humiliation and degradation to the Iraqi people."

After the prayers, worshippers burned American and Israeli flags and chanted: "No, America, no! No, agreement, no!"

In Kufa, al-Sadr supporters carried banners, including one that said: "We won't accept Iraq being an American colony!" Another said: "The suspicious agreement means the permanent occupation of Iraq."

U.S. and Iraqi forces routed Shiite militiamen loyal to al-Sadr in a spring offensive in Sadr City.

U.S.-Iraqi talks on the security agreement slowed over Washington's insistence on retaining sole legal jurisdiction over American troops in Iraq and differences over a schedule for the departure of the U.S. military.

Iraqi officials want all foreign troops out by the end of 2011. However, President Bush has resisted a firm timetable for withdrawing troops from Iraq.