Threat to blow up
The men threatened to blow up the children if they were not given safe passage, but eventually released them and fled towards Pakistan's tribal area bordering Afghanistan, tribal negotiators said.
In London, Pervez Musharraf, the Pakistani president, said after talks with Gordon Brown, the British prime minister, that the school siege vindicated his efforts to clamp down on pro-Taliban fighters.
Musharraf said the hostage-taking was a "a desperate act, maybe to take away attention from the military operation outside. I think we will keep going strong on the side of acting against the terrorists".
A member of the tribal elders' negotiating team said they were forced to let the seven hostage-takers go to keep the children, who were mostly aged eight to 12, alive.
"They were armed with dynamite, hand grenades, Kalashnikov rifles and other explosive material. They took 315 schoolchildren and 10 teachers hostage," Shah Abdul Aziz told the AFP news agency.
"When the team of tribal elders entered the school, the children were crying. They were hungry. Some had fainted due to fear. It was a very painful scene.
"During negotiations they repeatedly warned they would kill the children and blow up themselves if they were not allowed safe passage."
Elsewhere in the NWFP, authorities found the bodies of two decapitated policemen on Sunday night in the Swat valley, according to police.
Separately, the Pakistan military said heavy fighting was going on in two areas of South Waziristan on the Afghan border.
One soldier had been killed and nine wounded in the fighting on Monday, the military said.
More than 150 fighters and 20 soldiers have been killed in the South Waziristan fighting this month.
In neighbouring North Waziristan, two soldiers were killed in an attack on a checkpost, while three policemen were killed in another attack in the Orakzai tribal region on Sunday night, intelligence officials said.