The Tehrik-e-Taliban Pakistan (TTP), or Pakistan Taliban, which renewed an allegiance with the Taliban when the Islamist militant group took power in Afghanistan last August, claimed responsibility for the attack.

The militants tried to infiltrate Pakistan from Afghanistan in Hassan Khel area of North Waziristan district, Pakistani troops responded and foiled the attempt, the army said.

"Four soldiers were killed during the intense exchange of fire with the militants," the military's media wing said in a statement on Thursday night.

Militants also suffered heavy casualties, the statement said, quoting intelligence reports, but independent confirmation was not immediately possible because the districts along the mountainous Afghan border are off limits to journalists and human rights organisations.

Last month, at least five Pakistani soldiers were killed at a border post in northwestern Kurram district in a cross-border militant attack from Afghanistan.

(Reporting by Gul Yousafzai; Additional reporting by Saud Mehsud in Dera Ismail Khan, writing by Raza Hassan; editing by Grant McCool)

By Gul Yousafzai