The bombing took place in Butmaina in the Mohmand tribal district bordering Afghanistan where the army has been fighting against Taliban militants.
“At least 28 people have been killed and 30 others wounded,” deputy chief of the Mohmand tribal district administration Naveed Akbar said.
The bomber came in as Friday prayers were in progress and blew himself up in the main hall, he said.
The victims include four children, aged 10 or younger, who were killed in the attack, he said, adding that a curfew has been imposed in the area. Another local government official confirmed the information.
Shireen Zada, a resident who had prayed at another mosque nearby, said he heard the blast as he was walking home.
“I rushed to the spot and when I went inside the hall there was blood and human remains everywhere and people crying out,” he said.
“I brought my pick-up truck, loaded three wounded and drove them to the hospital in Khar,” he said, referring to the nearest town.
Prime Minister Nawaz Sharif condemned the bombing, saying the government would remain steadfast in their fight against extremists.
“The cowardly attacks by terrorists cannot shatter the government’s resolve to eliminate terrorism from the country,” read a statement from Sharif’s office.
Taliban faction Jamaat-ul-Ahrar (JuA) claimed responsibility for the attack, saying it was carried out to avenge the deaths of 13 of its members and arrests of others by a local vigilante force in 2009.
Since 2007 the government has encouraged vigilante forces comprising tribesmen – locally known as peace committees – to defend their villages against the Taliban.
“Today our suicide bomber has attacked the so-called peace lashkar (vigilante force) in Mohmand agency’s Anbar district,” the group’s spokesman Ehsanullah Ehsan said in an email to reporters.
“We warn all the lashkar members of Anbar and supporters of military to quit opposition to Islam and Jihad and refrain from enmity with Mujahedin (holy warriors) otherwise our war is being extended,” Ehsan said.
On September 2, at least 14 people were killed and more than 50 wounded after a suicide bomber attacked a court in the Pakistani city of Mardan in an assault targeting Pakistan’s legal community that was claimed by the JuA.
The group has also said it was behind an attack on lawyers in southwest Quetta, which killed 73 people on August 8, as well as the Lahore Easter bombing that killed 75 in Pakistan’s deadliest attack this year.
Pakistan’s deadliest ever attack occurred in Peshawar in December 2014, when Taliban militants stormed a school killing more than 150 people, mostly children.
The army launched an operation in June 2014 in a bid to wipe out militant bases in the north-western tribal areas and so bring an end to the bloody insurgency that has cost thousands of civilian lives since 2004.
As a result, security in the country has since improved. Scattered attacks still take place, but they are fewer and of a lesser intensity than in previous years.
According to data from the South Asia Terrorism Portal, 457 civilians and 182 members of the security forces were killed in Pakistan from January 1 to September 11, putting 2016 on course for fewer casualties than 2015.
Last year, the country recorded its lowest number of killings since 2007, when the Pakistani Taliban was formed.