The soldiers were on a reconnaissance mission in the Surobi district, about 30 miles east of the Afghan capital, when they were ambushed Monday afternoon. NATO sent backup and said a "large number" of the attackers were killed in the three-hour gunbattle.
France's top military official, Gen. Jean-Louis Georgelin, said most of the French casualties came in the minutes after the team was climbing a mountain pass. The fighting lasted into nightfall, he said.
"In its fight against terrorism, France has just been struck severely," French President Nicolas Sarkozy said in a statement. But he added, "My determination remains intact."
Qazi Suliman, the district chief in Surobi, said 13 militants were reported killed. One Western official described the attacks on the French as "complex."
Georgelin denied a statement from an Afghan security official that four French soldiers were kidnapped by insurgents and then killed. The Afghan official spoke on condition of anonymity because he was not supposed to release the information.
It was the deadliest attack against international troops in Afghanistan since June 2005, when 16 American troops were killed in Kunar province when their helicopter was shot down by a rocket-propelled grenade.
In July of this year nine U.S. troops died when insurgents attacked a base on the Kunar-Nuristan border in eastern Afghanistan.
The death toll could heighten domestic opposition to Sarkozy's plan to boost the French contingent by some 700 troops by the end of this month for a total of 2,600. Sarkozy said he plans to travel to Afghanistan to reassure French troops and that "France is at their sides."
In the attack on the U.S. base just a few miles from the border with Pakistan, militants failed to gain entry to Camp Salerno in Khost city after launching waves of attacks just before midnight on Monday, said Arsallah Jamal, the governor of Khost.
A suicide bombing outside the same base on Monday killed 10 civilians and wounded 13 others.
Ground forces, fighter aircraft and helicopters chased the retreating militants. NATO said its forces identified the attackers about 1,000 yards outside of the base perimeter and launched helicopter gunships.
Gen. Mohammad Zahir Azimi, the Afghan Defense Ministry spokesman, said Afghan soldiers, aided by U.S. troops, chased and surrounded a group of insurgents, and that six militants blew themselves up when cornered. Seven other militants died in those explosions and a rolling gun battle, he said.
"(The Afghan National Army) is saying that anytime we get close to them, they detonate themselves," Jamal said.
NATO offered a slightly different account, saying three suicide bombers detonated their vests and three more were shot dead. NATO said seven attackers in total were killed.
At least 13 insurgents and two Afghan civilians died, officials said.
The Taliban appeared to confirm the account. Zabiullah Mujahid, a Taliban spokesman, said 15 militants had been dispatched for the attack on Salerno. Seven blew themselves up and eight returned to a Taliban safehouse, he said.
Jamal said the bodies of at least two dead militants were outside the checkpoint leading to the base's airport, both wearing vests packed with explosives, Jamal said.
Militants have long targeted U.S. bases with suicide bombers, but coordinated attacks on such a major base are rare.
On Monday, the top U.S. general in the region, Maj. Gen. Jeffrey J. Schloesser, issued a rare public warning that militants planned to attack civilian, military and government targets during the celebration of Independence Day on Monday.
More than 3,400 people - mostly militants - have been killed in insurgency-related violence this year, according to an Associated Press count based on figures from Western and Afghan officials.
Associated Press writer Rahim Faiez in Kabul contributed to this report.