Attack helicopters destroyed the school compound in the village of Chingai before dawn on Monday, according to the Pakistani military.
The military said the site was away from other buildings in the North West Frontier province.
Shaukat Sultan, spokesman, said: "We received confirmed intelligence reports that 70 to 80 militants were hiding in a madrasa [school] used as a terrorist-training facility, which was destroyed by an army strike, led by helicopters.
"According to our local sources, up to 80 deaths have been confirmed," he said.
Sultan said there was no collateral damage, but Chingai's residents were seen collecting bodies of children from the rubble.
A local reporter told the Reuters news agency: "The bodies are beyond recognition. They are badly mutilated. Limbs were being collected by local people in cloth sheets."
A senior security official said Maulana Liaqatullah, a local religious leader who owned the school, was killed in the raid on the compound 10km north of Khar, the main town in the Bajaur tribal region.
Liaqatullah was wanted by the authorities for providing sanctuary to al-Qaeda members.
Helicopter gunships destroyed
a school compound
Siraj ul-Haq, a cabinet minister from the province, condemned the attack. He said he would resign from the government in protest.
"The government has launched an attack during the night, which is against Islam and the traditions of the area," he said during a funeral of one of the dead.
"They [the victims] were not given any warning. This was an unprovoked attack on a madrasa. They were innocent people."
Several hours after the attack, thousands of enraged tribesmen attended three mass funerals in a field near the madrasa.
Before the burial, the remains of at least 50 people were laid on traditional wooden beds placed side by side in rows and covered with coloured blankets. Locals walked among the beds and offered prayers.
A Pakistani official said that Faqir Mohammed, reportedly a local al-Qaeda leader, was believed to have been in the madrasa and left 30 minutes before the strike.
Mohammed addressed a crowd of 10,000 mourners at one of the funerals calling for widescale protests.
"We were peaceful, but the government attacked and killed our innocent people on orders from America," Mohammed said.
"It is an open aggression."
In Islamabad, Qazi Hussain Ahmed, an opposition political leader, also blamed the US for the attack and said claims that the madrasa was a terrorist training centre were "rubbish".
Thirty children were among the dead, he claimed.
"It was an American plane behind the attack and Pakistan is taking responsibility because they know there would be a civil war if the American responsibility was known," Ahmed, leader of a six-party religious alliance opposed to Musharraf, said.
"It was an American plane behind the attack and Pakistan is taking responsibility because they know there would be a civil war if the American responsibility was known."
Qazi Hussain Ahmed, leader of six-party alliance opposed to Musharraf
The attack scuppered with the planned signing of a peace deal between Bajur tribal leaders and the military along the lines of an accord signed earlier this year in nearby North Waziristan.
The Waziristan deal was aimed at stopping militants operating in the area and crossing into Afghanistan. US and Afghan officials believe the deal could make North Waziristan a terrorist haven.
Pakistan's military has been trying to stamp out pro-al-Qaeda and Taliban fighters operating inside the semi-autonomous tribal region and against US and Afghan forces across the border.