Security officials said the bomber was among the congregation
The explosion tore through the mosque, near the city of Peshawar, as about 1,000 people offered prayers for the Muslim festival of Eid al-Adha.
Aftab Sherpao, interior minister in the outgoing government, was in the congregation but was unhurt. His son was among about 100 people injured.
The violence comes as Pakistan prepares for a general election next month.
President Pervez Musharraf lifted a state of emergency on Saturday, saying the threat from Islamic militants had been contained.
We were saying prayers when this huge explosion occurred. It almost blew out our ear drums
Shaukat Ali, eyewitness
In pictures: Mosque attack
But in the past week there have been several suicide attacks.
US defence secretary Robert Gates said in the wake of the latest bombing that al-Qaeda had begun to focus on attacking the Pakistani government.
Officials said Friday's attacker had taken a place among the congregation, in the second row behind Mr Sherpao, at the mosque inside his own residential compound.
"Naturally, Aftab Sherpao was the target," the politician's spokesman Salim Shah told the AFP news agency.
Witnesses said the dead included some of his police bodyguards. He later visited some of the wounded in hospital.
It was the second apparent attack on Mr Sherpao - a close ally of President Musharraf - in eight months.
As interior minister in the government recently dissolved by the president ahead of elections, Mr Sherpao was the country's top security official and led the government's campaign against Islamic militants.
He is running again as a candidate for parliament in the election on 8 January.
President Musharraf issued a statement condemning the "distorted thinking" of the militants behind the "abhorrent act".
Dozens of security officials later raided an Islamic school in a nearby village and arrested seven students, Associated Press reported, although officials would not say if the raid was connected to the bombing.
Children's bodies
Police said the mosque bomb contained 6-8kg (13-17lb) of explosives and was filled with nails and ball bearings.
Witnesses described a scene of carnage inside the mosque, in the Charsadda district near Peshawar.
"We were saying prayers when this huge explosion occurred. It almost blew out our ear drums," said 26-year-old Shaukat Ali.
"I lost my two brothers," said a weeping Jehangir Khan, who said he had helped retrieve the bodies of six children.
Hamid Nawaz, the current interior minister, denied there was a security lapse. "Such an incident can happen at such a gathering," he told local television.
Correspondents say that it is unusual for militants to carry out attacks during Eid.
The BBC's Barbara Plett in Islamabad says there has been a wave of suicide bombings in the past six months, most in the north-west of the country and most aimed at army and government targets.
The attacks are blamed on pro-Taleban militants retaliating for military operations against them in the border areas near Afghanistan.
More than 600 people have been killed, including around 200 soldiers, in violence sparked by the ousting of armed militants from the radical Red Mosque in Islamabad in July.
In his comments, Mr Gates said al-Qaeda had "re-established itself" in the border areas.
"Al-Qaeda seems to have turned its face toward Pakistan and attacks on the Pakistani government and Pakistani people," he said.
Bei dem Freitagsgebet in einer Moschee in der Nähe von Peschawar in Pakistan sprengte sich ein Selbstmordattentäter in Luft. 

Von den etwa 1.000 versammelten Gläubigen, die sich während des Islamischen Opferfestes zum Gebet versammelt hatten, starben mindestens 54 Personen, darunter auch mehrere Bodyguards des Noch-Innenminsters Aftab Sherpao, der wahrscheinlich Ziel des Anschlags war. 

Bis zur Verhängung des Ausnahmezustandes in Pakistan Anfang November durch Präsident Pervez Musharraf war Sherpao der Verantwortliche für die Sicherheit und leitete Aktionen gegen islamische Militante. Der Präsident beauftragte Sicherheits- und Geheimdienste des Landes damit, die Hintermänner des Anschlags aufzuspüren. Der Kampf gegen Extremisten werde seiner Aussage nach fortgesetzt.

Erst Anfang der Woche hob Musharraf den Ausnahmezustand wieder auf. Die Parlamentswahlen sollen am 8. Januar wie geplant stattfinden.