At least three personnel of the Khasadar force and two civilians were killed in a suicide attack in Mohmand Agency's Ghalanai tehsil on Wednesday, the Inter-Services Public Relations (ISPR) said.
Three other people were injured in the attack, sources in the political administration said.
The proscribed Jamaat-ul-Ahrar (JA) group claimed responsibility for the attack in a statement emailed to journalists.
A suicide bomber tried to enter a housing colony of the local political administration. When he was stopped in this attempt by Khasadar personnel, the militant blew himself up outside the main gate of the colony, the sources said.
ISPR in a statement said two suicide bombers were involved in the "foiled" terror bid.
“One attacker came by foot and started firing at forces while the other was on a motorbike and rammed into the main gate of the complex,” Hamidullah Khattak, a local administration official in Mohmand, told AFP.
The first was shot dead by the sentries at the gate of the political administration office while the other blew himself up once spotted and challenged by security personnel at the gate, said the ISPR.
"Security agencies had the intelligence about intrusion of suicide bombers from Afghanistan inside Mohmand agency," it added.
Three security personnel and two civilians including a school teacher were killed in the blast and three others were injured, who were shifted to Lady Reading Hospital in Peshawar.
Security forces started a search and strike operation in the Ghalanai and Machni areas following the attack.
The incident comes barely two days after a suicide blast claimed by JA ripped through the camp of protesting chemists in front of the Punjab Assembly in Lahore, leaving 13 people dead
In September last year, a suicide bomber targeted a mosque in Mohmand Agency's Anbar tehsil during Friday prayers, leaving 36 people dead. That attack too was claimed by JA, a breakaway faction of the Tehreek-i-Taliban Pakistan.
Mohmand is one of Pakistan’s seven semi-autonomous tribal districts near the Afghan border, rife with homegrown insurgents and foreign militants.
Despite heavy military presence on both sides of the border, cross-border movements of militants (in both ways) have been a major area of concern.
Local militants have fled ongoing military offensives since 2008, taking refuge across the border and attacking Pakistani military checkpoints and civilians from there.
The army launched Operation Zarb-i-Azb in June 2014 in a bid to wipe out militant bases in the 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.