The attack occurred at about 13:15 local time (08:15 GMT) in the city of Kohat, Khyber Pakhtunkhwa province, as worshippers gathered for Friday prayers. A car bomb was detonated at the entrance of the mosque, and at least seven armed gunmen attempted to storm the police compound, exchanging fire with security forces.
Six of the attackers were killed in the explosion and ensuing gun battle, a Khyber Pakhtunkhwa Police spokesperson said. One suicide bomber also targeted the nearby office of an intelligence agency, according to police cited by ABC News.
The police compound housed counter-terrorism officers who had been conducting operations against militants across the province in recent years. Most of the dead and wounded were police officers attending prayers, said Bilal Faizi, a senior rescue official. Residents reported that the exchange of fire continued for hours after the initial blast.
Khyber Pakhtunkhwa Police suggested a faction of the Tehrik-e-Taliban Pakistan (TTP), also known as the Pakistani Taliban, carried out the attack. No group immediately claimed responsibility, but suspicion has fallen on the TTP, which has stepped up attacks on security forces in recent years.
Pakistan's President Asif Ali Zardari expressed his best wishes for the swift recovery of the injured and called for the "complete elimination" of foreign-backed terrorists. Prime Minister Shehbaz Sharif condemned the attack and directed authorities to accelerate rescue operations.
The attack comes a day after a roadside bomb struck a security forces convoy in the nearby Hangu district, killing six soldiers. Government troops also conducted raids on Thursday, killing 10 suspected TTP militants.