Army spokesman Major General Asim Salim Bajwa told reporters gunmen killed 141 people -- 132 students and 9 staff members -- in one of the deadliest attacks the country has seen in its 66-year history.
He said all seven militants were killed in the operation.
"The school has been cleared and handed over of school administration," Bajwa said.
"They [militants] did not come for the purpose of hostage. They stormed the school and started killing students and staff members", he added.
He said 7 army commandos have been wounded in the operation and two of them were in serious condition.
The gunmen began the siege by burning their vehicle, a sign that they had no intention of coming out alive, according to officials and eyewitnesses.
Dressed in uniforms of a local government-backed paramilitary, they scaled the school's walls and entered an auditorium where a farewell party for the year's graduates was taking place.
The militants immediately began firing on students, killing and injuring many of them, witnesses said.
“I was trying to snatch my cap from [my friend] Mustafa when I heard sounds of shots. Our class teacher, who was standing outside, entered the auditorium and shouted: Lay down, lay down,” Muddassir Shah told The Anadolu Agency from his bed at Lady Reading Hospital.
"She closed the auditorium’s main door and rushed to close the back door as heavy firing began outside. As we were trying to figure out what was happening, someone started hitting the main door, and in no time, broke it."
Another student, Mahmood Khan, said the attackers burst into his class and started firing.
"My mind was completely blank as bullets were hitting and injuring my colleagues,” Khan said. "I fell on the ground while trying to hide behind a table. All of a sudden, three blood-soaked bodies fell on me. Their blood soaked my body and clothes. I do not know how and why, but I closed my eyes."
The Tehrik-e-Taliban Pakistan militant coalition claimed responsibility for the attack, calling it a response to the Pakistani army's anti-militant operations in the Waziristan tribal area, which began on June 15.
"We selected the army's school for the attack because the government is targeting our families and females," Taliban spokesman Muhammad Umar Khorasani said. "We want them to feel the pain."
The army said it killed more than 1,500 Taliban militants in the past six months.
Prime Minister Nawaz Sharif said there will be no return from the ongoing military offensive against the Taliban.
"Terrorists have struck in our hearts, but let them know that military operations will continue until terrorists are eliminated," Prime Minister Nawaz Sharif said.
Meanwhile, at least 100 soldiers have been killed in landmine blasts and clashes with militants in the restive region.
The fight has since broadened to include other militant groups and has spread across the tribal belt, displacing 1.5 million people.
Since October, much of the fighting has been focused in Khyber Agency, 15 kilometers from Peshawar, where Taliban militants have found new havens.
This led to a new military operation called Khyber-One and a new wave of displaced tribesmen.