Taliban gunmen killed at least 20 people including 17 children after storming an army-run school in restive northwest Pakistan on Tuesday, officials said.
The militants had been ordered to shoot older students, a Taliban spokesman said, adding the attack was revenge for a major military offensive in the region.
At least five insurgents wearing military uniforms have entered the Army Public School in the city of Peshawar, a source at the school told AFP.
Pakistan's military headquarters said a "rescue operation" was under way and the bulk of staff and students had been evacuated.
A senior military official said troops had surrounded the school and television footage showed them taking up positions.
"Twenty people have been killed. Among them 17 are children, one is a male teacher and one a female teacher," Shahram Khan Tarakai, the health minister for Khyber-Pakhtunkhwa province, told AFP.
It was unclear who the 20th fatality was.
Sharif Khan, a doctor at Peshawar's Lady Reading Hospital, confirmed the toll.
A senior police official said a "huge blast" had occurred inside the building.
The Tehreek-e-Taliban Pakistan (TTP) claimed responsibility for the attack, saying it was retaliation for the army's continuing operation against militants in the North Waziristan tribal area close to Peshawar.
The school on Peshawar's Warsak Road is part of the Army Public Schools and Colleges System, which runs 146 schools nationwide for the children of military personnel and civilians. Its students range in age from around 10 to 18.
The schools educate the children of both officers and non-commissioned soldiers and army wives often teach in them.
A security official told AFP that hundreds of students and staff were in the school when the attack began, though it was not clear how many are still being held.
TTP spokesman Muhammad Khorasani told AFP there were six attackers.
"They include target killers and suicide attackers. They have been ordered to shoot the older students but not the children," he said.
"This attack is a response to Zarb-e-Azab and the killing of Taliban fighters and harassing their families."
Zarb-e-Azb is the official name for the army's offensive against strongholds of the Taliban and other militants in North Waziristan.
The military has hailed the operation as a major success in disrupting the TTP's insurgency, which has killed thousands of Pakistanis since it erupted in 2007.
More than 1,600 militants have been killed since the launch of Zarb-e-Azb in June, according to data compiled by AFP from regular military statements.
Talat Masood, a retired general and security analyst, said the attack was intended to weaken the military's resolve.
"It is both tactical and strategic. The militants know they won't be able to strike at the heart of the military, they don't have the capacity because the army are prepared," Masood told AFP.
"So they are going for soft targets. These attacks have a great psychological impact."
The semi-autonomous tribal areas that border Afghanistan have for years been a hideout for Islamist militants of all stripes -- including Al-Qaeda and the homegrown TTP as well as foreign fighters such as Uzbeks and Uighurs.
Washington pressed Islamabad for years to wipe out the sanctuaries in North Waziristan, which militants have used to launch attacks on NATO forces in Afghanistan.