At least four militants were killed in retaliatory fire by security forces when they launched a "suicide attack" on a camp of the Mohmand Rifles Headquarters in Mohmand Agency on Saturday.

Two soldiers of the Frontier Corps (FC) were killed in the attack in Ghalanai, DG Inter-Services Public Relations (ISPR) Asim Bajwa said on Twitter.

He said security forces had "defeated" the attack, killing all four suicide bombers. At least 14 FC men were injured in the attack.

The Jamaat-ul-Ahrar militant group claimed responsibility for the attack.

Four suicide bombers attempted to enter the camp at 6:20am and attack a mosque in a residential area where a large number of soldiers were attending morning prayers.

“Wearing suicide jackets, the attackers opened fire and tried to rush inside the mosque,” the ISPR said in a statement.

“Security forces surrounded the attackers. Two of the attackers blew themselves up while two others were shot dead,” it added.

The attackers were contained in the outer courtyard of the mosque.

A curfew was imposed in Mohmand Agency following the incursion as gunship helicopters searched the area.

Mohmand is one of Pakistan’s seven tribal agencies near the Afghan border where the military has been battling Al-Qaeda and Taliban-linked militants for over a decade.

The army launched operation Zarb-i-Azb in June 2014 in a bid to wipe out militant bases in the northwestern tribal areas. Security has since improved though scattered attacks still take place.

In September this year, a suicide bomber targeted a mosque in Mohmand Agency's Anbar tehsil during Friday prayers, leaving at least 24 people dead.