Islamabad: Militants said Saturday they had blown up a girls' school in Pakistan's restive northwest, the latest in a string of attacks on educational institutions.

There were no casualties, but the bomb destroyed three out of five classrooms of the government girls` primary school in Tiarza village of tribal South Waziristan, a local security official told AFP.

Azam Tariq, a spokesman for the "Sajna" arm of the Pakistani Taliban, claimed responsibility for the attack, saying the school had been targeted because it was run by the military and the group was opposed to female education.

Tariq told AFP that militants captured 18 people including school security guards and labourers before planting the explosive, but later released them.

Since 2002, when the army moved into northwestern tribal areas to fight the Taliban, militants have blown up hundreds of schools.

Pakistan`s army stepped up its offensive in the region after the Taliban`s massacre of 153 people, mostly school children, in Peshawar in December 2014, and killed or pushed hundreds of militants to Afghanistan.

Last month Taliban gunmen stormed a university in the northwestern town of Charsadda, killing 21 people in a chilling reminder of their ongoing ability to carry out occasional high-profile and brazen attacks.

Overall, levels of militant-linked violence have dropped dramatically, with 2015 seeing the fewest deaths among civilians and security forces since 2007 -- the year the Pakistani Taliban umbrella group was formed.

But the threat posed by the Taliban remains, particularly in the northwest.

Separately in the region on Saturday, Pakistani security forces killed at least five militants in a gunfight, the military said.

Troops encountered the militants near Ghalanai, the main town of Mohmand, one of the seven tribal districts bordering Afghanistan which have been home to Al-Qaeda and Taliban-led militants.

"Five terrorists were killed by security forces in Mohmand early morning today," a military statement said.

The clash comes after Taliban militants killed at least nine policemen in two almost simultaneous attacks in Mohmand on Wednesday.

Pakistan's Islamist insurgency began after the US-led invasion of Afghanistan in 2001, which led to a spillover of militants across the border and a surge in recruitment for Pakistani extremist groups.