PESHAWAR, Pakistan — Gunmen briefly seized control of a high school in volatile northwestern Pakistan on Monday, holding more than two dozen students and teachers hostage for hours before surrendering to tribal negotiators.

The gunmen gave themselves up after a five-hour standoff, with security forces ringing the school, Interior Ministry spokesman Javed Iqbal Cheema said.

The gunmen barged into the school near the town of Bannu after a chase and firefight with police that killed an eighth gunman and wounded a policeman.

The chase began after they abducted the health chief of a neighboring district and two of his relatives, who were later freed, also unharmed.

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

Cheema described the gunmen as "criminals" rather than Islamic militants.

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

Various had reported that between 200 and 250 children had been held inside the school at Wali Dar village, but after they were freed, local police chief Hamza Mehsud said only 25 children and seven teachers were detained inside a single classroom.

The fate of the gunmen remained unclear. Cheema said they were being held by the tribal mediators who were negotiating with police and the local government.

"The administration wants to take hold of the criminals but there are some traditions which have to be taken care of," Cheema told Geo television without elaborating.