The 10th-graders were having a class party when the gunmen burst into the auditorium. Disguised as Pakistani security forces and armed with automatic weapons, they moved through the crowd of cowering children, shooting methodically.
"I immediately hid beneath the desk," student Shah Rukh Khan said, "and they continued firing." The boy remained quiet, pretending to be dead as classmates collapsed around him, their dark green school uniforms soaked with blood.
When it was over, 132 children and nine staff members were dead Tuesday at an army-run school in this northeastern city in one of the deadliest terrorist attacks in Pakistan's troubled history. Many were shot in the temple at close range. One 9-year-old told his father that a classmate's head was nearly blown off.
Seven assailants wearing explosives-laden suicide vests fought a daylong gun battle with Pakistani soldiers and police commandos, trapping hundreds of students and teachers in the Army Public School compound where the attackers planted bombs to deter the security forces.
Around nightfall, eight hours after the siege began, army officials said all the militants had been killed and more than 900 students and teachers had escaped or been rescued.
Nearly all the children killed were between the ages of 13 and 16, and 121 students were wounded. School principal Tahira Qazi also was among the dead. The wounded lay in overwhelmed hospitals surrounded by anguished relatives as hundreds of people lined up outside to donate blood.
The Pakistani Taliban, a militant group seeking to overthrow the elected civilian government, claimed responsibility, saying it was retaliation for an army offensive against its hide-outs in the nation's restive northern tribal areas.
The military campaign began in the North Waziristan region in mid-June with tanks, troops and airstrikes, killing hundreds of militants with the Taliban and foreign militant networks based near the Afghan border. Up to half a million people were driven from their homes during the offensive, launched after the failure of a months-long effort by Prime Minister Nawaz Sharif's government to negotiate a peace deal.
The United States stepped up its own campaign of drone strikes in the region this year, though it has mainly targeted other militants who attack U.S.-led forces in Afghanistan.
The Pakistani Taliban group opposes formal education, particularly of girls, and has attacked hundreds of schools in recent years and — most notably — attempted to assassinate student activist Malala Yousafzai in October 2012 while she was riding on a bus. Malala, now 17, accepted the Nobel Peace Prize last week.
But this attack — which recalled the 2004 school siege in Beslan, Russia, that left 385 people dead, including 186 children — was the insurgents' biggest and most brazen, and it brought their long-running war into the homes of the military, Pakistan's most powerful institution.
The 1,100 students and staff members at the elite school, a sprawling campus surrounded by two residential colonies for serving and retired army officers, come mainly from upper-middle-class families of senior military personnel. Boys and girls in the first through the 10th grades attend the school, although witnesses said the assailants primarily targeted senior classes attended only by boys.
"My son is in shock," said Muhammad Amin, whose son, an 8th-grader, managed to escape soon after hearing the first shots. "His face has turned pale and he can't speak."
Rizwan Khan, an 11th-grader, was taking a test in a second-floor classroom and could see the auditorium through a window. As gunfire erupted, a teacher ordered the students onto the floor. A few moments later, teachers shouted at them to leave, and he ran across the tree-studded courtyard through a nightmarish scene.
"I saw bodies and wounded schoolmates on the main lawn of the school," he said.
President Obama condemned the "heinous attack" that he said showed the militants' "depravity." The United States had long urged Pakistan to go after Islamist fighters in the tribal region.
"We stand with the people of Pakistan, and reiterate the commitment of the United States to support the government of Pakistan in its efforts to combat terrorism and extremism and to promote peace and stability in the region," Obama said.
Malala, the Nobel laureate and education activist, released a statement saying she was "heartbroken" by the slaughter. "Innocent children in their school have no place in horror such as this," she said.
Even the Afghan Taliban, a separate group that is ideologically allied with the Pakistani branch, condemned the attack. "The intentional killing of innocent people, children and women are against the basics of Islam and this criteria has to be considered by every Islamic party and government," spokesman Zabiullah Mujahid said in a statement reported by Reuters news service.
Sharif, who flew to Peshawar to oversee the military operation, declared three days of mourning but said Pakistan would not waver in fighting terrorism.
"Such attacks are expected in the wake of a war and the country should not lose its strength," the prime minister said.
Yet the bloodshed shocked even the most hardened Pakistanis. At the Combined Military Hospital in Peshawar, a British-era facility regarded as the best in the city, blood stained the floors of the two-story outpatient ward, which was overrun with patients.
The bodies of 16 students and two teachers were lined up to be identified by families. Relatives, some wiping away tears with handkerchiefs and traditional caps, filed past the blood-soaked bodies wrapped in white sheets. All the victims had been shot in the head, some in the temple.
Muhammad Idrees came to look for the son of a family member who was out of the country, but couldn't find him. "He hasn't been traced until now," Idrees, in his 60s, said softly.
Witnesses said the assault began about 11 a.m. as gunmen dressed as security forces stormed the compound in two groups, some in a Suzuki van that burst through the back gate and others scaling a boundary wall. They went immediately to the main auditorium, where the 10th-graders had gathered, said Muhammad Irfan, a school employee.
Anti-terrorism police and elite army soldiers quickly arrived and engaged in a gun battle with the attackers, moving from building to building as explosions were heard across the area. Maj. Gen. Asim Bajwa, a military spokesman, said three of the militants were shot dead by snipers, three others were killed in an administrative building where they had holed up, and one was shot at the door of the auditorium.
In apparent response to the attack, the Pakistani military carried out 10 airstrikes in Khyber-Pakhtunkhwa province, of which Peshawar is the capital, "based on actionable intelligence," Bajwa said, without offering details.
The Pakistani Taliban, also known as Tehreek-e-Taliban Pakistan, or TTP, is a loose federation of militant groups that, though allied with the Taliban in Afghanistan, has a domestic focus. In September 2013, two suicide bombers linked to the insurgent group killed 127 people and injured more than 250 at a church in Peshawar, the deadliest attack ever on Pakistan's Christian minority.
The Pakistani military has claimed success in its offensive against the group's havens in the tribal region of North Waziristan, reportedly killing hundreds. But analysts say many militants escaped to neighboring areas, including Khyber-Pakhtunkhwa.
Tuesday's attack "clearly shows that the TTP has been able to maintain its operational network, particularly in Khyber-Pakhtunkhwa, which has emerged as a hub of militant activity," said Sameer Patil, a security analyst with Gateway House, a think tank in Mumbai, India.
A Pakistani Taliban spokesman, Muhammad Khorasani, told Pakistan's Express Tribune newspaper: "We will target every institution linked to the army unless they stop operations and the extrajudicial killing of our detainees."
Pakistani political opposition leader Imran Khan, who has opposed military action against the militant group and led months-long protests against Sharif's government, canceled a nationwide shutdown scheduled for Thursday. He condemned the killing of children, saying "we are united at this time of national tragedy."
After nightfall, provincial officials in Peshawar said that families had begun holding burial services.
Muhammad Mushtaq said his son, a fourth-grader, escaped but saw a classmate killed in front of him. Apparently in shock, the boy repeated over and over that a his friend's head was "torn apart" by a bullet. His mother was weeping inconsolably.
"I will take him to the psychologist tomorrow," Mushtaq said. "It is so horrible to imagine that our son saw death so close."