BAGHDAD — Assailants struck Shi’ite worshippers in three Iraqi cities today, killing at least 39 people in bombings and ambushes during the climax of ceremonies marking Ashoura, the holiest day in the Shi’ite calendar.

Tens of thousands of Shi’ite Muslims converged on the holy city of Karbala — where the seventh-century battle took place that cemented the schism between Sunnis and Shi’ites — beating their chest and heads to mark the death of the Prophet Mohammad’s grandson. The entire city was sealed off, all vehicles were banned, and pilgrims were searched at numerous checkpoints a day after the Iraqi army said it had foiled a plot by a messianic Shi’ite group to storm the nearby city of Najaf.

The bloodiest attack today occurred when a suicide bomber blew himself up among a crowd of worshippers entering a Shi’ite mosque, killing 19 people and wounding 54 in Mandali, a predominantly Shi’ite city northeast of Baghdad and near the Iranian border.

To the north, a bomb in a garbage can exploded as scores of Shi’ites — most them Kurds — were performing rituals in Khanaqin, a majority Kurdish city also near the Iranian border. At least 13 people were killed and 39 were wounded, police Maj. Idriss Mohammed said.

“I was participating in Ashoura ceremonies with my son and all of a sudden the bloodshed hit,” Abdul Jasim Hassan said, holding his 11-year-old son, Hussein, whose right leg was bleeding.

Nawal Hasson said she pleaded with her husband not to go to the ceremonies but went with him when he refused to stay home.

“I had a feeling that something might happen because terrorists are always targeting Shi’ites,” she said.

The two bombings occurred on the edge of Diyala province, not far from Baqouba, where fighting has raged for weeks between Sunni insurgents, Shi’ite militiamen and U.S.-Iraqi troops.

Gunmen in two cars also opened fire on a yellow minibus carrying Shi’ite pilgrims in the capital, killing at least seven people and wounding seven others, police said.

Iraqi police and military officials questioned hundreds of suspects rounded up after a weekend battle near Najaf aimed at preventing a major attack against leading Shi’ite clerics and pilgrims coinciding with Ashoura.

The U.S. military said Iraqi security forces went to the area on Sunday after hearing that gunmen from a messianic Shi’ite cult were disguising themselves as pilgrims in order to carry out a surprise attack on the holy city.

Iraq’s army said it killed the leader of the cult, called Soldiers of Heaven, in a 24-hour battle that ultimately was won with the support of U.S. and British jets and American ground forces.

The U.S. military said more than 100 gunmen were captured, but it did not say how many were killed. Iraq’s Defense Ministry, by contrast, raised its figures yesterday to say 263 militants were killed, 210 wounded and 392 captured.

Ministry spokesman Mohammed al-Askari said those detained included 35 women and 31 children following reports that the gunmen had brought their families with them to make it easier to infiltrate the city.

Despite the certainty of sectarian violence, millions of Shi’ites in Iraq were commemorating Ashoura, marching in processions and beating themselves bloody in a frenzied show of grief over the seventh-century death of Imam Hussein, one of the most revered Shi’ite saints.

Imam Hussein died in the battle of Karbala in A.D. 680. The battle cemented a schism in Islam between Shi’ites and Sunnis over leadership of the faith, a division that is at the heart of the sectarian violence that has spiraled in Iraq since the U.S.-led invasion in 2003, in particular since the Feb. 22 bombing of a Shi’ite mosque in Samarra.

Last year’s Ashoura commemorations were largely peaceful, but suicide bombers killed 55 Shi’ites in 2005 and twin blasts killed at least 181 people in 2004.

Under Saddam Hussein, pilgrims from Iran were banned and even Iraq’s Shi’ites, who make up about 60 percent of Iraq’s 27 million people, were restricted from performing the Ashoura rituals.