At least 27 people have been killed in a suspected suicide bomb attack and in subsequent violence at a religious procession in north-west Pakistan.
Much of Hangu's bazaar was destroyed in subsequent rioting
The explosion tore through a crowd of Shia Muslims marking the Ashura festival in the town of Hangu, sparking rioting among pilgrims.
Pakistan has a history of tension between Shia and Sunni Muslims.
Five people also died in Sunni-Shia fighting in Herat, western Afghanistan, on Thursday, doctors said.
The explosion in Hangu, in Pakistan's North-West Frontier Province, struck a bazaar as hundreds of people walked in a procession from the main Shia mosque in the town.
The army has sent in troops and a curfew has been imposed. No-one has claimed responsibility for the attack.
"We thought the bomb was detonated by remote control, but now it appears to be a suicide attack," local police chief Ayub Khan told the Associated Press news agency.
Dr Feroz Khan, district health officer for Hangu, told the BBC the number of injured was around 65.
Maulana Khurshid Anwar, a leader of the Shia procession, said the explosion had happened just as he was about to address the crowd.
District administrator Ghani ur-Rehman said the ensuing violence had destroyed 60% of the town's bazaar.
There were several reports of gunfire, with officials saying that four of the dead were killed in a gun attack on a minibus.
A judicial inquiry into the attack has been ordered, officials say.
Mr ur-Rehman said the situation had been brought under control by early afternoon, with Sunni and Shia religious leaders helping to calm the situation.
Shia cleric Allama Mehdi Najfi told AP from his base in Quetta in the south-west: "This attack has spread anger among our people throughout the country, but I appeal them not to clash with any member of other sects."
About 3,000 Shias protested on the streets of Karachi over the killings.
In Herat, Afghanistan, five people were killed and 27 hurt in clashes at a Shia procession for Ashura, doctors said.
Ashura marks the death of the Prophet Muhammad's grandson Imam Hussein, an event that led to the split between Shia and Sunni Muslims.