The bomber detonated explosives packed into a motorcycle in a narrow lane containing both the Shiite and a Sunni Muslim mosque in the town of Hangu, the latest bloody sectarian attack in a country where such violence is on the rise.
Pools of blood and pieces of human flesh littered the street after the attack, which also destroyed at least five nearby shops, witnesses said.
"It was a suicide attack which targeted Shiites but Sunni Muslims also fell victim since their mosque and some shops were also very close to the site," district police chief Mian Muhammad Saeed told AFP.
"We have found the head of the bomber, who came there on a motorbike," he said, putting the death toll at 21 with up to 50 others wounded, six of them in a critical condition.
Police said the bomb exploded as Shiites were leaving Friday prayers and Sunnis were going into their mosque for the main weekly sermon.
Hangu has long been a flashpoint for violence against minority Shiites, who make up an estimated 20 percent of Pakistan's population of 180 million.
It is close to Pakistan's semi-autonomous tribal belt on the Afghan border where Taliban and Al Qaeda-linked militants have carved out strongholds.
"The Shiite and Sunni mosques are very close to each other, and the explosion took place just as Shiites were coming out of the mosque and Sunnis were going into their mosque to say Friday prayers," said police official Imtiaz Shah.
Muzammil Hussain, a 28-year-old Shiite wounded in his head and hand, told AFP that he heard the blast as he left the mosque.
"As soon as I reached the mosque exit, a huge blast rocked the area. Many people fell on me with the impact of the blast," he said by telephone from the District Headquarters hospital (DHQ) in nearby Kohat.
"I saw red and bloodied pieces of human flesh everywhere. It was a scene I'd never seen in my life before. I was half conscious when people shifted me to a local hospital from where my family took me to the DHQ," he said.
Police constable Raaz Muhammad, who took part in the rescue effort, said the blast damaged two shops selling cosmetics and three trading in vegetables.
"I could see pieces of human flesh and big blood stains on the boundary walls of the mosque and on nearby shops," he said.
"The entire street was littered with sandals and caps of the people who were coming out of the mosque," he added.
There was no immediate claim of responsibility for the attack.
On January 10, a twin suicide attack killed 92 Shiites from the Hazara ethnic community in the southwestern city of Quetta -- the worst single attack on Shiites in Pakistan.
Lashkar-e-Jhangvi, Pakistan's most extreme Sunni terror group, claimed responsibility for the attack.
It is linked to both Al Qaeda and the Pakistani Taliban, Sunni fundamentalists who have fought an insurgency against the government since 2007.
Human Rights Watch (HRW) says it documented a sharp escalation in persecution of religious minorities in Pakistan in 2012, which it called the deadliest year on record for Shiites, with well over 400 killed in targeted attacks.
Activists accuse the government of failing to protect Shiites and say the perpetrators operate with impunity because the judiciary fails to prosecute them.
"Pakistan's human rights crisis worsened markedly in 2012 with religious minorities bearing the brunt of killings and repression," Ali Dayan Hasan, Pakistan director at HRW, said in the group's annual report.
"The government needs to show some backbone and act urgently to protect vulnerable communities such as the Hazara, or risk appearing indifferent or even complicit in the mass killing of its own citizens," he added.