At least 141 people have been killed and 122 injured in an attack by Taliban militants on a Pakistani high school.

At least 132 of the dead were schoolchildren, chief army spokesman General Asim Bajwa said.

Hundreds of students and teachers were taken hostage in the bloodiest insurgent attack in the country in several years.

The raid on the school lasted for more than eight hours before the gunmen were killed.

An unnamed source told Reuters that nine insurgents were killed while other sources reported six attackers, but noted they were all dead.

Loading...

The Pakistani military said special forces had rescued more than a dozen staff and students during the assault.

"The combat operation is over, the security personnel are carrying out a clearance operation and hopefully they will clear the building in a while," police official Abdullah Khan said.

"Dead bodies of six terrorists have been found in the building."

General Bajwa said on Twitter that the operation was "closing up" but explosive devices planted in school buildings by the militants were slowing clearance efforts.

Key points: At least 141 people killed, including 132 children

At least 141 people killed, including 132 children At least six Taliban militants who stormed the school are now dead

At least six Taliban militants who stormed the school are now dead More than 500 children of military personnel and civilians attend the school, mostly aged between 10 and 18

More than 500 children of military personnel and civilians attend the school, mostly aged between 10 and 18 The Taliban said the attack was in response to military operations

The Taliban said the attack was in response to military operations Peshawar is close to the North Waziristan tribal area where Pakistan's army is involved in operations against militants

Peshawar is close to the North Waziristan tribal area where Pakistan's army is involved in operations against militants The Pakistani Taliban is fighting for a strict Islamic state

The Taliban said they sent in six gunmen with suicide vests to attack the military run school.

Outside the school, helicopters had been hovering overhead and ambulances ferried wounded children to hospital.

The school on Peshawar's Warsak Road is part of the Army Public Schools and Colleges System, which runs 146 schools nationwide for the children of military personnel and civilians. Its students range in age from 10 to 18.

The schools educate the children of both officers and non-commissioned soldiers and army wives often teach there.

Disturbing reports have emerged of how the attack unfolded, according to Pakistani journalist Wajahat Khan, who is based in Islamabad.

"It started around home time, when most of the parents were about to receive the kids and school was about to get done," he told ABC News24.

Loading

"From what we know from military sources on the ground ... [the] assailants, all equipped with suicide jackets and all wearing local paramilitary and police uniforms, essentially walked into the school and started picking off kids, classroom by classroom."

Prime minister Nawaz Sharif condemned the attack and said he was on his way to Peshawar.

"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."

School targeted as 'response' to army killing Taliban fighters

The Tehreek-e-Taliban Pakistan (TTP) claimed responsibility for the attack, saying the gunmen had been ordered to shoot older students but not children.

A spokesman for the group said the attack was retaliation for the Pakistan army's continuing operation against militants in the North Waziristan tribal area close to Peshawar.

The school's students range in age from 10 to 18. ( Reuters: Khuram Parvez )

"They include target killers and suicide attackers," TTP spokesman Muhammad Khorasani told AFP.

"This attack is a response to Zarb-e-Azb and the killing of Taliban fighters and harassing their families."

Zarb-e-Azb is the official name for the army's offensive against strongholds of the Taliban and other militants in North Waziristan.

The offensive has killed more than 1,600 militants, according to an AFP tally.

The military has hailed the operation as a major success in disrupting Taliban militancy.

Loading

Retribution by the Taliban "was long expected because for the last several months there's been a sustained campaign against militancy," Mr Khan told the ABC.

"Pakistan was criticised for years for not doing enough [to fight the Taliban] ... This is payback."

The semi-autonomous tribal areas that border Afghanistan have for years been a hideout for Islamist militants of all stripes - including Al Qaeda and the homegrown TTP as well as foreign fighters such as Uzbeks and Uighurs.

The United States pressed Islamabad for years to wipe out the sanctuaries in North Waziristan, which militants have used to launch attacks on NATO forces in Afghanistan

International condemnation of 'vile', 'dastardly' and 'cruel' attack

Pakistani Nobel peace laureate Malala Yousafzai, who was shot in the head by the Taliban in 2012 for insisting that girls had a right to an education, said she was "heartbroken" by the killings.

"I am heartbroken by this senseless and cold-blooded act of terror in Peshawar that is unfolding before us," Malala, who now lives in England, said in a statement.

"Innocent children in their school have no place in horror such as this.

"I condemn these atrocious and cowardly acts and stand united with the government and armed forces of Pakistan whose efforts so far to address this horrific event are commendable.

"I, along with millions of others around the world, mourn these children, my brothers and sisters - but we will never be defeated."

Australian Prime Minister Tony Abbott said it was "impossible to put into words the mixture of grief and fury that must be felt by people in Pakistan and around the world at this latest terrorist atrocity."

US president Barack Obama condemned the raid and promised his country would stand by Pakistan in its struggle against violent extremism.

"By targeting students and teachers in this heinous attack, terrorists have once again shown their depravity," he said.

"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."

UN secretary-general Ban Ki-moon also expressed his shock at the attack.

"It is an act of horror and rank cowardice to attack defenceless children while they learn," Mr Ban said at the start of a UN Security Council meeting.

Loading

India's prime minister Narendra Modi and home minister Rajnath Singh both disparaged the attack on Twitter.

"I strongly condemn the terrorist attack on a school at Peshawar," Mr Singh said.

"This dastardly and inhuman attack exposes the real face of terrorism. My heart goes out to the families of those children who got killed by the terrorists in Peshawar."

India has repeatedly urged Pakistan to rein in militant groups operating on its soil.

India and Pakistan have fought three wars since independence in 1947, and deadly attacks on Mumbai by Pakistan-based militants dealt a blow to tentative peace talks in 2008.

French president Francois Hollande condemned the attack on the school as "vile".

"No words can express the ignominy of such an attack against children in their school," Mr Hollande said in a statement.

German foreign minister Frank-Walter Steinmeier said in a statement he condemned the "criminal attack in the strongest terms".

"The hostage-taking and murder of children exceeds in its cruel cowardice all that Pakistan, stricken by years of terror and violence, has known before," he said.

"We mourn with the people of Pakistan the victims of this bloody terrorist attack. Our hearts go out to the families of the victims. For the many injured we wish speedy recoveries."

Rescue workers and family members carry the coffin of a student killed in the attack. ( Reuters: Khuram Parvez )

ABC/wires