Police said three police officers and a soldier were killed at the Kakki station near Bannu, Geo News reported.
Militants used hand grenades at the station, which was occupied by about 20 officers, and then fired at the mosque, killing five people who were leaving after prayers, officials said.
A gunfire exchange lasted at least 90 minutes, police said.
At least seven security officers were injured.
The banned Tehrik-i-Taliban Pakistan, known as the TTP, claimed responsibility, Geo News said.
Police said four suicide attackers detonated their explosives when they were surrounded by security forces deployed from Bannu. One attacker, believed to be 12 years old, fled.
The Associated Press of Pakistan reported President Asif Ali Zardari Monday condemned the attack.
Tehrik-i-Taliban Pakistan spokesman Ehsanullah Ehsan told the Pakistani news website Dawn.com the attack was in retaliation for the recent killing of Ibrahim Mehsud, a nephew of former TTP leader Baitullah Mehsud.
Kate Middleton recycles dress at movie premiere
Benedict Cumberbatch's dramatic reading of R. Kelly lyrics is just what you need