The clashes started after the ultras hijacked four trucks transporting ammunition and supplies for the army.
Paramilitary Frontier Corps personnel backed by artillery, tanks and gunship helicopters clashed with pro-Taliban militants in the Darra Adam Khel area in North West Frontier Province (NWFP).
The Frontier Corps had cleared important heights south of Spina Thana and 25 to 30 militants were killed in the fighting, the army said in a statement.
The security forces and militants also exchanged fire at the Kohat Tunnel and the troops stopped the movement of ultras in that area.
Two Frontier Corps personnel were killed and 10 others injured in the fighting, the statement added.
Reports said militants had captured a security forces outpost at Kotal and taken 20 troops hostage in the Darra Adam Khel region but there was no official confirmation of this.
Four tanks and two gunship helicopters backed the Frontier Corps troops conducting a search operation to recover the hijacked trucks and to clear the area of militants.
The militants were targeting the security forces with heavy machine guns, missiles and rockets, Dawn News channel reported.
The whole of Darra Adam Khel was cordoned off by troops and the tense situation in the area prompted many people to flee their homes.