The Taliban said the gunmen had been equipped with suicide vests. Three explosions were heard inside the high school at the height of the massacre, raising fears of more casualties.
Outside, as helicopters rumbled overhead, police struggled to hold back distraught parents who were trying to break past a security cordon and get into the school.
Officials said 122 people were wounded. A local hospital said the dead and injured were aged from 10 to 20 years old.
According to early witness accounts, a group of militants burst into the school as students attended classes and lectures, shooting indiscriminately at both pupils and teachers.
Read MorePakistani Taliban attack airport in Karachi, 27 dead
The gunmen, who several students said communicated with each other in a foreign language, managed to slip past the school's tight security because they were wearing Pakistani military uniforms, local media reported.
Pakistanis, used to almost daily militant attacks, were shocked by the scale of the massacre and the loss of so many young lives.
It recalled the 2004 siege of a school in Russia's Beslan by Chechen militants which ended in the death of more than 330 people, half of them children.
The Pakistani Taliban have vowed to step up attacks in response to a major army operation against the insurgents in the tribal areas.
But despite the crackdown this year, the military has long been accused of being too lenient towards Islamist militants who critics say are used to carry out the army's bidding in places like Kashmir and Afghanistan.
So far the Taliban have targeted mainly security forces, military bases and airports, but attacks on civilian targets with no logistical significance are relatively rare.
In September, 2013, however, dozens of people, including many children, were killed in an attack on a church, also in Peshawar in Pakistan's northwest.
The assault on a school where officers' children studied could push the armed forces into a more drastic response, analysts said.
In Peshawar, with the rescue operation still under way, hospitals overflowed with hundreds of wounded children, teenagers and adults.
"Classes 8-10 were in a special seminar on first aid in the main hall when students heard gunshots and then countless men burst in and opened fire," said Shahrukh Khan, in his mid-teens, who was shot in both legs.
"Teachers and the principal were also there. The men who burst in were speaking and shouting in an incomprehensible language. Sounded like Arabic or Farsi."
Read MorePakistan's 'Terror Tax'
Another student told Pakistan's Dunya Television: "The attackers had long beards, wore shalwar kameez (traditional baggy clothes) and spoke Arabic."
Prime Minister Nawaz Sharif condemned the attack.
"I can't stay back in Islamabad. This is a national tragedy unleashed by savages. These were my kids," he said in a statement.
"This is my loss. This is the nation's loss. I am leaving for Peshawar now and I will supervise this operation myself."
In India, Pakistan's long-term rival, Prime Minister Narendra Modi echoed Sharif's sentiments.
"It is a senseless act of unspeakable brutality that has claimed lives of the most innocent of human beings - young children in their school."
Pakistani teenager Malala Yousafzai, joint winner of this year's Nobel peace prize for her education campaign work, said she was devastated by the news.
"I am heartbroken by this senseless and cold-blooded act of terror in Peshawar that is unfolding before us," Malala, who now lives in central England, said in a statement.