“We were in the education hall when militants barged in, shooting,” said Zeeshan, a student, speaking at a hospital. “Our instructor asked us to duck and lay down and then I saw militants walking past rows of students shooting them in the head.”
Mushtaq Ghani, the information minister for Khyber-Pakhtunkhwa Province, confirmed that most of the victims had been killed by gunshots to the head.
As Pakistani security forces responded, some of the attackers blew themselves up while others were killed by members of the army’s Special Service Group commando unit.
Desperate parents, meanwhile, rushed to local hospitals or gathered outside the school gates seeking news of their children. One of them, Muhammad Arshad, described his relief after his son Ehsan was rescued by army commandos.
“I am thankful to God for giving him a second life,” he said.
Witnesses described the scene on Tuesday in Peshawar in northwestern Pakistan after at least 145 people were killed in a Taliban attack on a school.
But at the Combined Military Hospital, the bodies of schoolchildren were lined up on the floor, most of them with single gunshot wounds to the head.
A 7-year-old student, Afaq, said militants had entered his classroom and immediately started shooting. “They killed our teacher,” he said, breaking down in tears.
“These attackers were not in the mood to take hostages,” a security official said. “They were there to kill and this is what they did.”
Some students managed to flee. Television coverage showed panic-stricken pupils in green sweaters and blazers, the school uniform, being evacuated from the compound. Others were wounded and were taken to another hospital in the area, Lady Reading, where parents also gathered looking for news of their children.
Lady Reading Hospital later published a list of students known to have died; many of the dead have not yet been identified.
By late afternoon, the army said it had cleared three sections of the school compound and that troops were pushing through the remaining sections. After the last of the militants was killed, officials said, soldiers were sweeping the compound for explosives.
Prime Minister Nawaz Sharif arrived in Peshawar, where the authorities declared three days of mourning. Mr. Sharif announced an emergency meeting of all political parties in the city for Wednesday. In a statement, the foreign ministry said it was “deeply shocked” by the attack but that the government was undeterred in its fight against the Taliban.
The British prime minister, David Cameron, called the attack “deeply shocking” and said it was “horrifying that children are being killed simply for going to school.” The American ambassador to Pakistan, Richard G. Olson, said the United States “stands in solidarity with the people of Pakistan.”
And Malala Yousafzai, the teenage education campaigner from northwestern Pakistan who was awarded the Nobel Peace Prize in a ceremony last week, said she was “heartbroken by this senseless and coldblooded act of terror.”
“Innocent children in their school have no place in horror such as this,” Ms. Yousafzai said in a statement. “I, along with millions of others around the world, mourn these children, my brothers and sisters — but we will never be defeated.”
The Army Public School in Peshawar is part of a network of schools that the military operates in garrison towns and major cities across Pakistan. Students from army families have preferential access, but many of the students and teachers in the schools come from civilian backgrounds.
The assault came at a time of political turbulence in Pakistan. The opposition politician Imran Khan, whose party controls the provincial government in Khyber-Pakhtunkhwa, has been staging protest rallies in major cities in a bid to unseat Mr. Sharif, claiming that Mr. Sharif’s supporters rigged the 2013 elections.
Mr. Khan has criticized army operations in the tribal areas and called on the government to negotiate with the militants instead of fighting them, a stance that has attracted wide criticism.
The Pakistani Taliban, always a loose and chaotic coalition of militant groups, have come under increased pressure this year because of internal frictions and the military’s continuing operation in North Waziristan, which started in June following an audacious attack on the Karachi airport.
The military says that the offensive, officially known as Operation Zarb-e-Azb, has resulted in the death of 1,800 militants and cleared much of North Waziristan, the region’s most notorious hub of militant activities.
Still, the school attack on Tuesday demonstrated that the Taliban remain willing and able to strike at vulnerable civilian targets.
Ihsanullah Tipu Mehsud contributed reporting from Peshawar, and Declan Walsh from London.