The Ministry of Interior (MoI) said the militants were busy planting the bomb in Khushal Khel village in Syed Karam district.
MoI further added that the incident took place around 6:00 pm local time as the explosives went off prematurely, leaving five militants dead and eight others wounded.
According to MoI, the local residents did not suffer any casualties in the explosion.
The Taliban militants and insurgents belonging to the other militant groups frequently use Improvised Exposive Device (IED) to carry out attacks.
This comes as at least 3 people were killed and over 70 others were wounded after an IED was detonated in a mosque in eastern Nangarhar province of Afghanistan.
The incident took place as scores of people had gathered in Hisarak Jami Mosquee in Rodat district.
At least 31 children were also among those injured in the attack while the mullah, one man and one child were among those killed.