ISLAMABAD - Pakistan said Saturday an intense gunfight with militants near the border with Afghanistan has killed seven soldiers, including an officer.

The clash in North Waziristan erupted while security forces were conducting a counter-terrorism operation based on intelligence information in the remote region, said an army statement.

"A group of terrorists was reported to have infiltrated from across (the border) and hiding in a compound," it added.

Pakistani security forces raided the compound and killed nine "terrorists" in the ensuing "intense exchange of fire." The area has been cleared and bodies of the slain militants have been taken into custody to ascertain their identities, according to the military's media wing, known as ISPR.

The Waziristan region until recently used to be a major training ground for local and foreign militants, including Taliban insurgents waging a deadly insurgency inside Afghanistan.

The Pakistan military launched a major ground and air offensive in North Waziristan back in 2014 and has since cleared more than 90 percent of the region of all terrorist groups, according to officials.

Pakistan is unilaterally building a robust fence and new military posts to secure the nearly 2,600 kilometer traditionally porous and open border with Afghanistan. Officials hope the construction effort will block terrorist infiltration in both directions.