Gunmen released more than two dozen students and teachers from a school in northwestern Pakistan on Monday after holding them for several hours, witnesses said.

pakistan-school-cp-4246597

Armoured police vehicles sit parked outside a school where students and teachers were taken hostage in Bannu, Pakistan, on Monday. ((Ijaz Mohammad/Associated Press))

As many as six gunmen surrendered to police following the five-hour standoff, which took place in the town of Bannu.

In return for releasing the captives and giving up their weapons, the gunmen received safe passage and left the area, said one negotiator, former lawmaker Shar Abdul Aziz. Local police declined to comment on that report.

Police say the standoff started after the gunmen abducted a health official in a neighbouring district and were chased down by police. The gunmen eventually freed the official but took refuge inside the school.

"It was incidental that those criminals entered the school," Pakistani President Pervez Musharraf told a news conference during a visit to London on Monday. "It has been resolved peacefully."

There had been conflicting reports on how many people were inside the school. Early reports said about 30 students and teachers were being held while Pakistan's interior minister said 250 were involved.

Bannu lies near the volatile tribal region of North Waziristan, a stronghold of Taliban militants near the Afghan border.

With files from the Associated Press