SHAHI KOTO, Pakistan - A roadside bomb killed three U.S. soldiers and partly destroyed a girls' school in northwest Pakistan on Wednesday in an attack that drew attention to a little-publicized American military training mission in the al Qaeda and Taliban heartland.

They were the first known U.S. military fatalities in Pakistan's lawless tribal regions near the Afghan border and a major victory for militants who have been hit hard by a surge of U.S. missile strikes and a major Pakistani army offensive.

The blast also killed three schoolgirls and a Pakistani soldier who was traveling with the Americans. Two more U.S. soldiers were wounded, along with more than 70 other people, mostly students at the school, officials said.

The attack took place in Lower Dir, which like much of the northwest is home to pockets of militants. The Pakistani army launched a major operation in Lower Dir and the nearby Swat Valley last year that succeeded in pushing the insurgents out, but isolated attacks have continued.

The Americans were traveling with Pakistani security officers in a five-car convoy that was hit by a roadside bomb close to the Koto Girls High School. The blast flattened much of the school, leaving books, bags and pens strewn in the rubble.

"What was the fault of these innocent students?" said Mohammed Dawood, a resident who helped police dig the injured from the debris.

The soldiers were part of a small contingent of American soldiers training members of the paramilitary Frontier Corps, Pakistan's army and the U.S. Embassy said. The mission is trying to strengthen the ill-equipped and poorly trained outfit's ability to fight militants.

The soldiers were driving to attend the inauguration of a girl's school, which had been renovated with U.S. humanitarian assistance, the embassy said in a statement. The school that was flattened in the blast was not the one where the convoy was heading, though it had been damaged by a militant attack last year, security officials said.

The blast was detonated by remote control, police said. It hit the vehicle in which the Americans were traveling along with members of the Frontier Corps, suggesting the attackers were targeting the Americans, according to Amjad Ali Shah, a local journalist traveling with the convoy to cover the school opening.

The attack will highlight the presence of U.S. troops in Pakistan at a time when anti-American sentiment is running high. U.S. and Pakistani authorities rarely talk about the American training program in the northwest out of fear it could generate a backlash.

Despite the presence of tens of thousands of U.S. forces in neighboring Afghanistan, Pakistan does not permit American troops to conduct military operations on its soil.

In a statement, the U.S. Embassy said three American military personnel were killed and two were wounded in the bombing. The Pakistani government also condemned the attack in a statement that referred to the dead Americans only as U.S. nationals.

The last Americans killed in an attack in Pakistan was American aid worker in the northwestern city of Peshawar in 2008.

Two Pakistani reporters traveling in same convoy as the Americans said that Pakistani military guides referred to the foreigners traveling with them as journalists. Initial reports of the attack, which proved incorrect, said four foreign journalists had been killed.

Mohammad Israr Khan, who works for Khyber TV, said two of the foreigners were wearing civilian clothes, not uniforms or traditional Pakistani dress.

"When our convoy reached near a school in Shahi Koto, I heard a blast," Shah, the journalist said. "Our driver lost control and something hit me and I fell unconscious."

The Frontier Corps training program was never officially announced, a sign of the sensitivity for the Pakistani government of allowing U.S. troops on its territory. It began in 2008.

Frontier Corps officials have said the course includes classroom and field sessions. U.S. officials have said that the program is a "train-the-trainer" program and that the Americans are not carrying out operations.

After the bombing, the bodies of three foreigners and two injured were flown by helicopter to Islamabad and then taken to the city's Al-Shifa hospital, said a doctor there who asked his name not be used citing the sensitivity of the case. One of the injured had minor head wounds and the other had multiple fractures. The injured were later taken to a Pakistani military air base and flown out of the country, the doctor said.

Pakistani army and intelligence officers were present and did not allow visitors into the building.