The defence minister reported that Pakistani security forces killed all 33 hostage-takers as they retook a police station that had been captured.
On Sunday, Islamist insurgents from the Pakistani Taliban took control of the centre in the isolated Bannu district of the northwest.
There were several people inside at the time, including security personnel.
All hostages were released, two special forces were killed, and between ten and fifteen military personnel were hurt, according to Khawaja Muhammad Asif, the defence minister.
According to a statement quoted by local media, the TTP (also referred to as the Pakistani Taliban) acknowledged responsibility for the assault.
The group stepped up its attacks after ending a ceasefire with the government last month. The two sides have been locked in conflict for years.
The group emerged in 2007 and was suppressed by a military operation in 2014, before re-emerging.
It is separate to the Afghan Taliban, though it has been more active since the Afghans agreed a peace deal with the US in 2020, and took control of the country last year. The two groups share a hard-line Islamist ideology.
The hostage incident unfolded in a region near the two countries’ shared border.
Explaining events, Mr Asif told parliament that the 33 militants had links to different groups, and were being held in a counter-terrorism compound.
He said the hostages were taken after one militant hit a guard on the head with a brick and snatched his weapon.
The militants are said to have requested a safe exit in return for releasing the hostages. A standoff emerged as negotiation efforts failed.
Army commandoes are said to have taken the chance to take back the police station at 12:30 local time (07:30 GMT) after the hostage-takers found themselves arguing among themselves.
Witnesses of the siege reported explosions and heavy gunfire.
Mr Asif told parliament that “all the terrorists” had been killed, and all the hostages freed – without specifying what the latter number was.
He blamed a “total collapse” of the provincial Khyber Pakhtunkhwa government for the deadly incident.
Nearby schools, businesses and roads remained closed on Tuesday, with police checkpoints in place.
The incident came amid a wave of deadly attacks in Pakistan – many of these targeting the security forces.
Four policemen were killed during a separate attack elsewhere in Bannu on Sunday.