A series of bombings tore through a Shiite pilgrimage in Baghdad and a Kurdish rally in northern Iraq on Monday, killing at least 40 people and wounding scores more, police said. At least two of the attackers were apparently female homicide bombers, the U.S. military said.

The attacks were a devastating blow to growing confidence among the Iraqi public in recent security gains that have seen the level of violence in Iraq drop to its lowest levels in more than four years.

The violence began in Baghdad, when a roadside bomb and three homicide attackers exploded in quick succession among crowds of Shiite pilgrims, killing at least 28 people and wounding 92, police and hospital officials said.

The attacks occurred as tens of thousands of worshippers streamed toward a shrine for an annual event marking the death of an eighth century saint, which climaxes on Tuesday.

A senior U.S. military official blamed Al Qaeda in Iraq for the attacks in Baghdad and said two of the bombers were believed to have been women.

The official, who spoke on condition of anonymity because he was releasing the information ahead of a formal statement, gave a slightly lower casualty toll of 20 killed and 70 wounded.

In a separate attack, a bomb killed at least 12 people and wounded 80 others at a Kurdish rally in the northern city of Kirkuk, Iraqi authorities said. They were protesting a draft provincial elections law which has been blocked in parliament because of disagreement over a power-sharing formula in the disputed city of Kirkuk, an oil-rich area.

Authorities were investigating whether the blast was caused by a female bomber or explosives at the site, Maj. Gen. Jamal Tahir, a Kirkuk police spokesman, said.

Police also found a car bomb nearby and destroyed it without causing casualties after evacuating the area, Tahir said.

The attacks in Baghdad took place in the mainly Shiite Karradah district, which is several miles (kilometers) away from the goal of the pilgrimage in Kazimiyah, northern Baghdad.

Mustapha Abdullah, a 32-year-old man who was injured in the stomach and legs, said the blasts took place when pilgrims from Baghdad's predominantly Shiite southeastern neighborhood of Zafaraniyah reached Kahramanah Square in Karradah.

"I heard women and children crying and shouting and I saw burned women as dead bodies lied in pools of blood on the street," said Abdullah, speaking at al-Kindi hospital where he was being treated. "I couldn't help myself then I became unconscious and found myself here at hospital."

The majority of the dead were women and children, police and health officials said. The injured were treated in five hospitals, they said.

It was the bloodiest attack in Baghdad since June 17, when a truck bombing killed 63 people in Hurriyah, a Baghdad neighborhood that saw some of the worst Shiite-Sunni slaughter in 2006.

Insurgents have increasingly been using women this year to stage homicide bombings in a bid to avoid security measures. Women are more easily able to hide explosives under their all-encompassing black Islamic robes, or abayas, and they often are not searched at checkpoints.

But security forces have deployed about 200 women security personnel this week to search female pilgrims near the Baghdad district of Kazimiyah, where the Shiite saint is buried in a golden domed shrine.

On Sunday, at least seven pilgrims were killed south of Baghdad in an ambush by gunmen near a Sunni town, Madain, south of the capital, according to Iraqi police and hospital officials.

The marchers were commemorating the death in 799 A.D. of Imam Moussa al-Kadhim.

Since the 2003 ouster of Saddam Hussein, who was a Sunni, Shiite political parties have encouraged huge turnouts at religious festivals to display the majority sect's power in Iraq. Sunni religious extremists have often targeted the gatherings to foment sectarian war, but that has not stopped the Shiites.

In 2005, at least 1,000 people also were killed in a bridge stampede caused by rumors of a homicide bomber in Baghdad during the Kazimiyah pilgrimage.

But recent pilgrimages have been relatively peaceful as a U.S. troop buildup, a Sunni revolt against al-Qaida in Iraq and a Shiite militia cease-fire helped drive violence down to its lowest level in more than four years.

Sunday's ambush occurred in a former Al Qaeda in Iraq stronghold that has been touted by the U.S. military as a success story with its streets now patrolled by U.S.-allied Sunni groups known as Awakening Councils.

The main Iraqi military spokesman in Baghdad, Brig. Gen. Qassim al-Moussawi, on Sunday said 100,000 Iraqi security forces will be deployed along with U.S. reinforcements and air support to protect the ceremonies in Kazimiyah.

Vehicles have been banned from the area and most Baghdad bridges would be closed to traffic, al-Moussawi said, adding that pilgrims were banned from carrying weapons or cell phones — rules that have been widely flouted in the past.

The Kazimiyah ceremonies have in the past attracted around 1 million pilgrims. They have often been chaotic, with the task of protecting the pilgrims stretching police resources.