Local TV footage shows the devastation wrought by the powerful explosion
Three US soldiers have become the first known American military fatalities in Pakistan as they died in a bomb near a school in the north-west.
Three schoolgirls were among the dead while 70 people, including another 63 schoolgirls and two US soldiers, were injured in the explosion in Lower Dir.
The US embassy said the military personnel had been training Pakistan's Frontier Corps in counter-insurgency.
Both governments deny large numbers of US troops are in Pakistan.
The US embassy in Islamabad confirmed in a statement three American military personnel were killed and two wounded in what it branded a "vicious terrorist bombing".
M Ilyas Khan, BBC News, Islamabad
The Pakistani military and the government are both extremely sensitive about the strong US presence in their country and both appear to be saying different things to different audiences.
Officially the government says it is deeply concerned about increasing numbers of US diplomatic and aid staff who have appeared in the country since US President Barack Obama declared the country to be a top foreign policy priority.
The Pakistani authorities have on several occasions during the past five months arrested American officials - in Lahore and Peshawar - who were suspected of having incorrect paperwork.
But unofficially the government is believed to be relying on US effort and expertise to fight the Taliban.
The statement also said the Americans had been due to attend the inauguration of a girls' school recently renovated with US humanitarian assistance.
Azam Tariq, a spokesman for the Pakistani Taliban, Tehreek-e-Taliban, claimed responsibility for the attack in a statement to AFP news agency.
Military spokesman Maj Gen Athar Abbas told the BBC that the US personnel were attached to the Frontier Corps as military trainers.
Pakistan's Frontier Corps is a paramilitary force responsible for operations against militants in the volatile north-west, near the Afghan border.
The US soldiers were said to have been travelling in a convoy, along with Pakistani troops, that was heading to the inauguration of a newly built girls' school in Maidan, an area of Lower Dir district in the North West Frontier Province.
The bomb - which police said was activated by remote control - occurred near a different school in Koto, a heavily populated village along the route.
The impact flattened much of the Koto Girls' High School, leaving pupils crying for help under the rubble.
At least three of the dead were schoolgirls, police said, adding that security guards and three local journalists were also among the wounded.
The Taliban has often targeted girls' schools in recent years
News that three US soldiers were killed will be highly embarrassing for the Pakistani government, which is acutely aware of the unpopularity of its close ties to Washington, says the BBC's Ilyas Khan in Islamabad.
Critics accuse Pakistani President Asif Ali Zardari of turning a blind eye to repeated American drone attacks in the north-west, which have killed more than 600 people during the past year, our correspondent says.
The US has argued in the past that its soldiers are in Pakistan to provide security for US citizens, he adds.
Last year, the Pakistani army carried out a major offensive to drive Taliban insurgents out of Lower Dir and the neighbouring districts of Swat and Buner.
But the Taliban are still present in remote areas and the latest attack shows that the militants remain a powerful force in the region, says the BBC's Mark Dummett in Islamabad.
Prime Minister Yousuf Raza Gilani also condemned the attack and ordered an investigation, the AFP news agency reports.
The Taliban has frequently targeted girls' schools in recent years, burning several to the ground. Many are now being rebuilt.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.