Hours after the attack, the Pakistani military was still exchanging gunfire with the militants inside the Army Public School and Degree College, in the violence-plagued city of Peshawar, about 120 kilometers (75 miles) from the country's capital, Islamabad.
Two explosions were also heard.
By 3 p.m. Tuesday, it was unclear how many of the hundreds of students were still inside the school.
The Pakistani military said it had pushed the attackers to four blocks of the school, and killed four.
The death toll has steadily risen, and officials fear it will climb higher. The number of injured was upwards of 100.
Most of those who died were between the ages of 12 and 16, said Pervez Khattak, chief minister of the Khyber Pakhtunkhwa province, where Peshawar is located.
Scaling the walls
In a telephone call to CNN, the Pakistan Taliban -- Tehreek e Taliban Pakistan (TTP) -- said six suicide bombers scaled the walls of the school with orders to kill older students about 10 a.m.
The Taliban said "300 to 400 people are under the custody of the suicide bombers."
The military had earlier said most students and teachers had been evacuated.
Mohammed Khurrassani, the TTP spokesman, told CNN the attack was revenge for the killing of hundreds of innocent tribesmen during repeated army operations in provinces including South Waziristan, North Waziristan and the Khyber Agency -- all restive regions along Pakistan's border with Afghanistan.
For the past few months, the Pakistan military has been conducting a ground offensive aimed at clearing out militants in these areas. The campaign has displaced tens of thousands of people.
Northwestern Pakistan is home to loosely governed tribal areas. It's also a base for foreign fighters and a refuge for members of the Taliban and other militant groups.
The military offensive in the region has spurred deadly retaliations.
In September, choir members and children attending Sunday school were among 81 people killed in a suicide bombing at the Protestant All Saints Church of Pakistan. A splinter group of the Pakistani Taliban claimed responsibility for the church attack, blaming the U.S. program of drone strikes in tribal areas of the country.
Prime Minister Nawaz Sharif rushed to Peshawar, declared three days of mourning, and said he would personally oversee the operation to flush out the militants.
As recently as last spring, The Taliban and the Pakistani government were involved in peace talks. The government released 19 Taliban noncombatants in a goodwill gesture.
But talks broke down under a wave of attacks by the Taliban and mounting political pressure to bring the violence under control.