Taliban gunmen stormed a Pakistani Air Force base early on Friday, killing at least 17 people, a military spokesman said, the deadliest attack on a military installation this year.
Sixteen of the dead were killed in a mosque as they offered morning prayers, and a captain died leading the counter-attack against the raiders, 13 of whom were killed, Major General Asim Bajwa said on Twitter.
It was unclear if the 16 killed in the mosque at the Badaber air base in the northwestern city of Peshawar were civilians or military, he added.
"Terrorists entered camp at two points. Encounter began immediately," Bajwa tweeted. The attackers "were contained within a close area. Meanwhile a group rushed to mosque, martyred 16 offering prayers."
He posted pictures of bloodied bodies, most of them wearing black traditional Pakistani costume, known as shalwar khameez, and white running shoes.
Earlier, a military official at the base said six gunmen were killed in return fire from security guards as they tried to fight their way into the facility.
"All the terrorists were wearing explosives-laden jackets and were armed with hand-propelled grenades, mortars, AK-47 rifles," the official, who asked not to be identified, told Reuters.
Military officials were searching villages near the base, which is about 10 km (6 miles) south of the center of Peshawar city, he added.
Explosions and gunfire could still be heard more than three hours after the attack began, nearby residents said, while television broadcast images of helicopters hovering above the base with police and ambulances gathered outside.
Ambulances took about 20 wounded military to hospital, said rescue official Bilal Ahmed.
"We proudly claim responsibility for the attack on Pakistani air base," Taliban spokesman Muhammad Khorasani told Reuters. This base is being used by fighter jets for bombing us."
The number of attacks in Pakistan has fallen around 70 percent this year, as the military has launched an offensive against Taliban bases along the Afghan border and government ha stepped up measures to fight militancy.
That follows a massacre at a military-run school last December that killed about 150 people, almost all of them children.
But militants still strike high-value targets, despite the fall-off in attacks. The home minister of Punjab province was among 16 people killed in a suicide attack last month.