At least 50 people were killed when a suicide attacker detonated a powerful bomb inside a mosque in northwest Pakistan, apparently targeting a former interior minister.

The former minister, Aftab Sherpao, was unhurt, but his son and dozens of others were injured.

Pakistani President Pervez Musharraf condemned the attack and directed security and intelligence agencies to track down those responsible.

The mosque, located inside Sherpao's compound near the city of Peshawar, capital of Northwest Frontier Province, was crowded with worshippers offering prayers for the Muslim Eid al-Adha festival. Survivors described a scene of carnage with body parts and blood-spattered prayer caps littering the mosque.

The bombing was the second assassination attempt in eight months on Sherpao, who has been an outspoken critic of Islamic militants.

He served as the country's top law enforcement official until last month when the government was dissolved ahead of next month's parliamentary elections.

United Nations chief Ban Ki-moon said he was appalled by the bombing and condemned the act of terrorism carried out at a house of worship.

The U.S. State Department also condemned the attack and sent condolences to the families of the victims and the Pakistani people.

Friday's bombing was the deadliest attack in Pakistan since October, when twin suicide bombings killed 139 people at a parade to welcome formerly exiled opposition leader and former Prime Minister Benazir Bhutto.

Over the past year, Islamic militants have repeatedly targeted the Pakistani army and top officials in the government of President Musharraf, a key ally in the U.S.-led war on terror.