BAGHDAD — A series of bomb blasts and gunfire attacks swept Iraq on Wednesday, mostly targeting Shiites who were marking one of their holiest religious events.

At least 27 people were killed in nine attacks that stretched to the northern cities of Tikrit and Mosul and to the regions west of Baghdad and Falluja.

The attack with the largest number of casualties was in Baquba, north of Baghdad, as a group of Shiite pilgrims began observing Ashura, the solemn religious commemoration of the martyrdom of Imam Hussein, a grandson of the Prophet Muhammad.

As Shiite mourners hit themselves in unison in a traditional public demonstration of grief, three improvised bombs ripped through the crowd, killing nine people and wounding 35, medical and security officials said.