A group of armed men have released about 250 schoolchildren and teachers they were holding hostage in north-west Pakistan, government officials say.
The men took the captives in Bannu district, North West Frontier Province, after fleeing police.
The group of about seven armed men gave themselves up to tribal elders, who were conducting talks. Some reports say they were given safe passage.
No children were hurt during the incident, the officials said.
Pakistani President Pervez Musharraf said that the hostage-taking was a "desperate act" by "extremists".
He vowed to crack down on militants in the area, which is known for Islamist activity.
"The criminals have surrendered to the jirga [tribal council] along with their weapons. No children have been hurt and all have been released," interior ministry spokesman Javel Iqbal Cheema told local TV.
Security is a growing problem in Bannu district
But local TV reports said the children were only freed after the government promised the men safe passage. Local police made no comment on the report.
Shar Abdul Aziz, one of the negotiators, told the Associated Press the hostage-takers had threatened to kill the schoolchildren, the teachers and themselves if attacked.
Police say the men had kidnapped a health department official from the neighbouring district of Karak on Monday.
They were then challenged by police but refused to stop at a police check post and went on to take over the school in an area called Domial, some 15 km north of Bannu town, the main town in the district.
Mr Musharraf said it had not been their intention to seize children.
"They didn't go really to take the children as hostage," he said during a visit to London.
"It was incidental that they entered the school to hide themselves. But in the process to hide they took those students hostage."
Initial reports said the hostage-takers were Islamist militants but other reports describe them as common criminals.
Security in and around Bannu has been a growing problem.
Pro-Taleban militants control large areas of neighbouring North and South Waziristan. In recent months they have been increasingly active in Bannu district.
Last October at least 15 people were killed in Bannu town by a suicide bomber dressed in a burka.