The raids appear part of an insurgent strategy to step up attacks in widely scattered parts of the country as the U.S. focuses its resources on the battle around the Taliban's southern birthplace of Kandahar.
Also Saturday, three more American service members were killed - two in a bombing in the south and the third in fighting in eastern Afghanistan, the U.S. command said. That brought to 38 the number of U.S. troops killed this month - well below last month's figure of 66.
The militant assault in the border province of Khost began about 4 a.m. when dozens of insurgents stormed Forward Operating Base Salerno and nearby Camp Chapman with mortars, rocket-propelled grenades and automatic weapons, according to NATO and Afghan police.
Two attackers managed to breach the wire protecting Salerno but were killed before they could advance far onto the base, NATO said. Twenty-one attackers were killed - 15 at Salerno and six at Chapman - and five were captured, it said.
Three more insurgents, including a commander, were killed in an airstrike as they fled the area, NATO said.
The Afghan Defense Ministry said two Afghan soldiers were killed and three wounded in the fighting. Four U.S. troops were wounded, NATO officials said.
U.S. and Afghan officials blamed the attack on the Haqqani network, a Pakistan-based faction of the Taliban with close ties to al-Qaida. Camp Chapman was the scene of the Dec. 30 suicide attack that killed the seven CIA employees.
Afghan police said about 50 insurgents took part in the twin assaults. After being driven away from the bases, the insurgents approached the nearby offices of the governor and provincial police headquarters but were also scattered, said Khost provincial police Chief Abdul Hakim Ishaqzai.
"Given the size of the enemy's force, this could have been a major catastrophe for Khost. Luckily we prevented it," he said. Small-arms fire continued through the morning, while NATO helicopters patrolled overhead. The dead were wearing U.S. Army uniforms, which can be easily purchased in shops in Kabul and other cities, possibly pilfered from military warehouses.
The twin attacks appeared to be part of a growing pattern of insurgent assaults far from the southern battlefields of Kandahar and Helmand provinces, which have been the main focus of the U.S. military campaign. Last December, President Barack Obama ordered 30,000 reinforcements to Afghanistan, most to the Kandahar area where the Islamist movement was organized in the mid-1990s.
On Saturday, a candidate running for a seat in parliament from Herat province in northwestern Afghanistan was shot and killed on his way to a mosque, said Lal Mohammad Omarzai, deputy governor of Shindand district. He said two men on a motorbike opened fire on Abdul Manan, a candidate in the September balloting. He later died of his wounds.
Late Friday, insurgents stormed a police checkpoint in Takhar province near the northern border with Tajikistan. The Interior Ministry said nine insurgents were killed and 12 wounded with no losses on the government side. The day before, Taliban fighters killed eight Afghan policemen in a raid on a checkpoint outside the northern city of Kunduz.
And on Wednesday, an Afghan police driver with family links to the Taliban killed three Spaniards - two police trainers and their interpreter - at a training center in the northern province of Badghis.
A joint NATO-Afghan investigative team found the shooter, whose brother-in-law is a Taliban commander, had been arrested and disarmed a year ago for links to insurgents but was reinstated after two local elders vouched for him, NATO said in a statement Saturday.
Although the Afghan capital is relatively secure, incidents apparently directed at female students have raised concern about Taliban intimidation within the city.
The Health Ministry said 48 pupils and teachers at the Zabihullah Esmati High School were rushed to hospitals Saturday after falling ill with breathing problems and nausea. All but nine were treated and released after blood samples were taken to try to determine the cause.
On Wednesday, dozens of students and teachers at another Kabul girls' school became sick when an unknown gas spread through classrooms, education officials said. The cause of that incident has not been determined, but officials fear the apparent poisonings could be part of an insurgent campaign to frighten girls from attending school.
Also Saturday, the government criticized U.S. media reports that alleged numerous Afghan officials had received payments from the CIA. A presidential office statement did not address or deny any specific allegations, but called the reports an insult to the government and an attempt to defame people within it.
The New York Times reported Thursday that the CIA had been paying Mohammed Zia Salehi, the chief of administration for Afghanistan's National Security Council, who was arrested last month as part of an investigation into corruption. The Washington Post reported the next day the agency was making payments to a large number of officials in President Hamid Karzai's administration.
"Afghanistan believes that making such allegations will not strengthen the alliance against terrorism and will not strengthen an Afghanistan based on the law and rules, but will have negative effects in those areas," the statement by Karzai's office said, without commenting on the substance of the reports.
"We strongly condemn such irresponsible allegations which just create doubt and defame responsible people of this country," it said.
Meanwhile, NATO issued a statement saying coalition helicopter pilots were not responsible for the deaths of three Afghan policemen killed Aug. 20 in what had been considered a friendly fire incident in Jowzjan province's Darzab district.
It said the helicopters showed up hours after fighting began and it was possible the three had been killed earlier.
All Afghan forces had also been ordered to remain inside compounds at the time the two helicopters fired a missile and 80 30-millimeter rounds at an insurgent firing position, NATO said.