Militants attacked a Pakistani security force fort in the South Waziristan region on the Afghan border on Tuesday killing five soldiers and wounding seven, the military said.
The militants attacked the Ladha fort and an observation post an hour after midnight on Monday.
"Security forces retaliated with fire causing heavy casualties ... the attack was beaten back," the military said in a statement.
The exact number of militants killed could not be ascertained, it said.
Violence has intensified in recent days in South Waziristan, where an al Qaeda-linked militant leader blamed by Pakistani authorities and the United States for the December 27 assassination of opposition leader Benazir Bhutto is based.
The militant commander, Baitullah Mehsud, has been blamed for a string of attacks in recent months, compounding a sense of crisis in the nuclear-armed country as President Pervez Musharraf has struggled to hold power in the face of protests from opponents.
On Wednesday last week, militants loyal to Mehsud attacked and captured another fort in the region in a serious setback for the military.
Two days later the military said up to 90 militants were killed in two clashes, including an attack on gunmen gathering to attack Ladha fort.
A spokesman for the militants denied the heavy losses.
The government says the militants are intent on destabilizing the country.
Security forces have been battling al Qaeda-linked militants in South Waziristan for several years. The mountainous region, occupied by conservative, independent-minded Pashtun tribesmen, has never come under the full authority of any government.
This file picture taken April 2007, shows Pakistani soldiers at a military checkpost in South Waziristan