A suicide bombing ripped through a Shi'ite 'procession Thursday in northwestern Pakistan, sparking riots during the Muslim sect's most important holiday. At least 27 people were killed and dozens injured in the violence, officials said. Army troops took control of the area and a curfew was imposed as the Shiites vented their anger by burning shops and cars in Hangu, about 200 kilometers southwest of the capital, Islamabad, district police chief Ayub Khan said. Khan said 23 people died in the bombing and riots that followed. Officials reported gunfire between groups of rioters and security forces. Aziz ur-Rahman, a commander of the paramilitary Frontier Constabulary, said that three men and a woman died in a separate shooting on a minibus on the outskirts of the town. Ghani ur-Rehman, the top district administrator, said that more than 50 others were wounded in the day of violence. He said more than 60 percent of the town bazaar had been burned down. Mohammed Jamil, 25, who witnessed the blast, said that a procession of about 300 Shi'ites had come out of the Imam Barga Quami, a mosque, and were passing the bazaar when the explosion went off, causing bloodshed and bedlam. "I saw dead bodies and injured people crying. There was panic everywhere. Some people rushed to the injured and dead bodies, others went to houses and took out weapons and knives and kerosene oil and started setting fire to shops, destroying everything," he said. Akram Durrani, the top elected official in the province, said a preliminary investigation showed the attack was a suicide bombing. He announced a judicial inquiry into the attack. The Shi'ites were marking Ashoura, which mourns the 7th century death of Imam Hussain, a grandson of the Prophet Muhammad. Hussain's death fueled a rivalry between Shi'ites and Sunnis over who should succeed the prophet. Police mounted road blocks on the road to Hangu. At Ustarzai, a town about 25 kilometers away, police said they had orders to let no one pass, and even stopped three ambulances. Two trucks of police from an anti-terrorist squad were able to drive by. Meanwhile, hundreds of Shi'ites and Sunnis clashed in a western Afghan city Thursday, exchanging fire, hurling grenades and burning mosques, officials said. At least five people were killed and 51 injured, a doctor said. Islamic extremists are suspected to have incited the violence, said Ismatullah Mohammed, a senior police officer. The fighting followed three days of rioting across Afghanistan over drawings of the Prophet Muhammad, first published in a Danish newspaper. Those riots left 11 dead. Thursday's fighting started after 300 Sunnis threw stones at a Shi'ite mosque during Ashoura, Mohammed said. Such an attack is rare in Afghanistan, where there has been little tension between the two sects. The Shi'ites responded, attacking Sunnis in a camp for displaced people, before the violence spread across the city with both sides throwing grenades at each other, burning about a dozen cars and two mosques, he said. Police fired into the air to try to separate the two sides, but failed, said local resident Abdul Nafai. Barakatullah Mohammedi, a doctor at Herat Hospital, said at least five people were killed and 51 injured. Sunnis make up about 80 percent of Afghanistan's 28 million population, Shi'ites 20 percent. Apart from a small clash in the capital Kabul during Ashoura last year, there has been little fighting between the two sects.