The terrorists entered Bajaur Agency via the Kagha Pass. They were tracked down by security forces and surrounded by a cordon near the Ghatki Kaga area, said a statement issued by the Inter-Services Public Relations (ISPR).
The militants were killed when they attempted to escape.
One of the militants opened fire at the personnel and was shot dead in retaliatory action, while another blew himself up.
Suicide jackets, anti-tank mines, magnetic mines, prepared remote-controlled Improvised Explosive Devices, remote-controlled receivers, detonators and communications equipment "bearing (an) Afghan mobile company's signature" were recovered from them, the statement said.
More From This Section
The bodies of the militants were shifted to Headquarters Hospital in Khar.
The security has been tightened at all the entry and exit points to the area.
Bajaur is an agency of the Federally Administered Tribal Areas (FATA) of Pakistan. It is the smallest of the agencies in FATA.
According to Ministry of States and Frontier Regions, FATA has been the country's worst hit region due to terrorist attacks in the last four years.
A total of 3,062 people have been killed in terrorists attacks in the region since 2013-14, the ministry said in a report.