Security forces killed 15 militants in an hour-long gunbattle overnight after they targeted the Khazina police post in Hangu district in Khyber Pakhtunkhwa province, which borders Afghanistan, police official Irfan Khan said on Thursday.
No group immediately claimed responsibility for the assault.
Suspicion is likely to fall on the Pakistani Taliban, known as Tehrik-e-Taliban Pakistan, or TTP, which has stepped up attacks on Pakistani security forces in the region in recent months.
Among those killed was Diyar Khan, a senior police officer who led reinforcements to the scene, according to a provincial police statement on Thursday.
More than two dozen police officers were wounded in the attack.
Police said the militants attacked the police post with heavy weapons.
Reinforcements dispatched to the scene were ambushed en route, damaging an armoured personnel carrier before officers fought back, according to the statement.
The attack came days after a suicide bombing killed 15, including 12 Pakistani army soldiers in the nearby district of Tank.
The TTP claimed responsibility for that attack.
Pakistan has witnessed a surge in militant violence in recent years, much of it blamed on the TTP, a close ally of the Afghan Taliban, who returned to power in neighbouring Afghanistan in 2021.
Islamabad has repeatedly accused Afghanistan's Taliban government of providing sanctuary to TTP militants, an allegation Kabul denies.