The attackers suffered "heavy causalities" in the pre-dawn attack on Lahda Fort and a nearby observation post in South Waziristan, while seven soldiers also were wounded, the military said in a statement.
The violence in the border region, as well as a series of suicide attacks that have killed hundreds in recent months, is triggering uncertainty in the country ahead of Feb. 18 elections that many predict will weaken President Pervez Musharraf's grip on power.
More than 100 rebels and soldiers are reported to have been killed in the region this month alone.
On Jan. 10, insurgents also attacked Lahda Fort. The military said then that between 40 and 50 of the attackers were killed. Last week, the militants overran a second fort in the region, leaving up to 22 soldiers dead or missing in a major embarrassment for the military.
The latest attack on Lahda Fort came hours before Adm. William Fallon - the head of the U.S. Central Command and top commander of American forces in the Middle East - arrived in Pakistan to meet with army chief Ashfaq Kayani, the Pakistan army and the U.S. embassy said.
The agenda for his talks was not released.
The border region emerged as a front line in the war on terror after Pakistan allied itself with the U.S. following the Sept. 11, 2001, terrorist attacks. Washington has given Pakistan billions of dollars in aid to help government forces battle militants.
The region, which has never been fully under the control of the central government, is believed to be home to Baitullah Mehsud, a militant leader blamed by Pakistan and the CIA for masterminding the Dec. 27 assassination of opposition leader Benazir Bhutto in a gun and suicide attack.
A purported spokesman for Mehsud warned the military to stop its attacks in the region.
"The army is killing innocent people in our areas and we will take strong action by attacking soldiers wherever possible, if it does not stop such activities," Maulvi Mohammed Umar told The Associated Press by phone.
The military said in a statement that five soldiers were killed and seven others wounded in the latest attack on Lahda Fort.
Umar said one Islamic fighter died and two others were wounded in the attack. He said the militants captured 13 troops in the action, a claim denied by the military.
"Tehrik-i-Taliban Pakistan warns the government to stop using brutal force in South Waziristan," he said, referring to the organization that claims to be an umbrella group for militant fighters in the tribal areas. "If it is not stopped, we will respond with full force in the entire country."
Meanwhile, security agencies arrested a suspected militant in the southern city of Karachi in connection with the attack on Bhutto, an intelligence official told the AP.
Yousuf Mehsud, who the official said was a close aide to Baitullah Mehsud, was detained late Monday after a tip-off, said the official, who requested anonymity because of the sensitivity of the issue.
Last week, authorities arrested a 15-year-old boy they said was part of the team sent to kill Bhutto.
The developments came after Pakistan's most popular private television network, Geo TV, went back on the air after signing a government code of conduct that critics say is muzzling independent media.
All stations banned by Musharraf during a state of emergency he declared in November are now broadcasting again, but concerns remain that the former general has whittled away at media freedoms as the country gears up for parliamentary polls. The state of emergency ended on Dec. 15.
The station declined to comment on whether there were any conditions, with its president saying only that the government's lifting of the ban was "a wise and wonderful move."
"As elections are coming up, more media coverage would make the elections more credible and contribute to the positive development of the country," said Geo President Imran Aslam.
Immediately after emergency rule was imposed, Geo was banned along with all private news networks, which had been reporting freely on growing challenges to Musharraf's U.S.-backed rule as well as surging violence by Muslim extremists.
Over the ensuing 10 weeks, the government permitted the other stations to return to the air as they signed the code of conduct, but Geo initially refused to go along.
While there are restrictions, media are in some ways more free in Pakistan than in many other Asian countries. Newspapers and TV stations report openly on anti-government protests, and opinion pages are full of articles calling on Musharraf to step down. Opposition leaders are frequently quoted alleging he is a dictator.