A Taliban attack on a Pakistani military base has killed 29 people including 16 worshippers who were gunned down when the militants stormed a mosque inside the compound during prayers.
The attack triggered an hours-long firefight at the base on the outskirts of Peshawar and Pakistani forces said they killed 13 attackers, although it was unclear how many were involved in the assault.
Apart from 16 killed inside the mosque,13 air force and army employees at the base were also killed by the militants, officials said.
The attack was a major blow for Pakistan's military, which has stepped up operations against the militants after a horrific Taliban attack last December at a Peshawar school that killed 150 people, mostly children.
In the latest assault, attackers first stormed the guard room of the Badaber base, according to air force officials.
Army spokesman Major General Asim Saleem Bajwa said 13 attackers were killed by security forces and the attack was quickly repulsed.
Details about how the Taliban managed to make their way into the mosque, which is inside the compound walls, and gun down 16 people during prayers were sketchy.
Maj Gen Bajwa said the militants entered the base from different directions in a two-pronged assault - apparently one push targeted the mosque - but security forces quickly responded. It is unclear if any attackers escaped.
According to Maj Gen Bajwa and a statement released by the air force, 29 people were wounded in the firefight. The dead and most the wounded were taken to a military hospital in the area.
Shortly after the attack, a suspected US drone strike hit a home in the South Waziristan tribal region, south of Peshawar, killing at least three militants and wounding five, according to two Pakistani security officials.
Pakistan's powerful army chief, General Raheel Sharif, rushed to Peshawar and met the security forces taking part in the clearing operation.
A spokesman for the Pakistani Taliban, Mohamad Khurasani, claimed the attack. In a statement to the media, he said 14 Taliban fighters were involved in the assault. They offered "safe passage" to women and children after attacking the base, he added.
Pakistani TV footage showed army helicopters hovering near the base as police and troops surrounded the area.
Local police officer Shahid Khan Bangash said a large explosion was heard as the militants first tried to storm the base. "We are hearing that the attackers were armed with guns and rockets," he said. Mr Bangash said the attackers threw grenades at the guard room but were unable to enter the main area of the base.
Air force chief Sohail Aman had briefed prime minister Nawaz Sharif on the attack, the air force said.
The assault came a day after Pakistan reported the arrest of a militant figure behind a recent failed attempt to target an air force facility in Kamra, also in the north-west of the country. Counter-terrorism officer Junaid Khan, in the southern port city of Karachi, where the raid took place, identified the suspect as Umar Hayat and said he was being questioned.