Pakistan's prime minister has vowed to rid his country of terrorism after a Taliban attack at a school in Peshawar killed 141 people, mostly children.
Nawaz Sharif spoke after talks between political parties about the massacre.
Gunmen went from class to class shooting the students in the Pakistani Taliban's deadliest attack to date. Funerals of the victims are continuing.
The Afghan president says the "time has come" for his country to work with Pakistan to fight "extremism."
Ashraf Ghani said the two countries should "jointly take effective actions" following a surprise meeting with Pakistan's army chief in Kabul to discuss security co-ordination.
New images of the school published by a BBC team that gained access to the site on Wednesday showed the scale and brutality of the attack, with pools of blood on the ground and walls covered in pockmarks from hundreds of bullets.
The Pakistani Taliban (TTP) said they had carried out the attack against the Army Public School to avenge army-led operations against them in the Khyber and North Waziristan areas.
Prime Minister Nawaz Sharif said Pakistan stood united to ensure the deaths of the children were not wasted, after meeting party leaders in Peshawar on Wednesday.
In any action against the militants, he said, there would be no distinction between "good and bad" Taliban.
"We...have resolved to continue the war against terrorism till the last terrorist is eliminated," he added.
He also announced an end to the moratorium on the death penalty for terrorism cases, which correspondents say is a move aimed at countering a view held by many Pakistanis that many terror suspects end up evading justice.
After meeting Pakistan's army chief General Raheel Sharif on Wednesday, Afghanistan's President Ghani said the two countries should "work together in sincerity and jointly take effective actions against terrorism and extremism".
In the past, the two countries have accused each other of allowing cross border attacks by militants.
At the scene: Mishal Husain, BBC News
It was a very eerie atmosphere. These were premises that should have been alive to the sound of hundreds of children who studied here and began school as normal on Tuesday. But it was now desolate.
The army has been working through the night to clear the premises of explosives.
There were blood stains running right down the steps and towards the auditorium itself.
There was a child's shoe on one of the steps. The auditorium, where children were taking exams, was one of the places within the school grounds that the militants first targeted.
The chairs that the children were sitting on had been upturned, the place has been turned upside down and I could see the blood stains on the floor right around me.
Pakistani Taliban (TTP) leader Mullah Fazlullah is believed by the Pakistani authorities to be hiding in Afghanistan, and media reports in Pakistan suggest the school attack may have been co-ordinated from Afghanistan.
But the TTP said the attack had been masterminded by its military chief in the Peshawar region, who it said had been in touch with the gunmen throughout the assault.
A TTP spokesman told the BBC they had deliberately killed older pupils and not targeted "small children".
BBC correspondents say the Taliban statement is being seen as damage limitation after the attack was universally condemned in Pakistan for its brutality.
World leaders voiced disgust at the attack. Even the Afghan Taliban have criticised the attack, calling it "un-Islamic".
The TTP also repeated its earlier claim that only six attackers were sent, contradicting official accounts that seven gunmen were killed.
The Taliban attackers wearing bomb vests cut through a wire fence to gain entry to the school, before launching an attack on an auditorium where children were taking an exam in a siege that lasted eight hours.
"This is not a human act,'' military spokesman Major General Asim Bajwa said during a tour of the school on Wednesday, the Associated Press reports. "This is a national tragedy."
A total of 125 people were wounded at Peshawar's Army Public School, which teaches boys and girls from both military and civilian backgrounds.
Mohammad Hilal, a student in the 10th grade, was shot three times in his arm and legs when the gunmen stormed the school auditorium.
"I think I passed out for a while. I thought I was dreaming. I wanted to move but felt paralysed. Then I came to and realised that actually two other boys had fallen on me. Both of them were dead," he told the BBC.
Prayer vigils are being held nationwide, with Pakistani embassies across the world lowering their flags to half-mast and opening books of condolences.
India's parliament observed a minute's silence in honour of the victims.
Hundreds of Taliban fighters are thought to have died in the recent Pakistan army offensive in the Khyber area and North Waziristan, regions close to the Afghan border.
- 1. At about 10:00 on Tuesday local time (05:00 GMT), seven militants were seen scaling the walls of the Army Public School in Peshawar. The gunmen, all wearing explosive vests, are believed to have snapped the barbed wire at these points and then used a ladder to enter the compound.
- 2. The first shots were heard from in front of the school's main hall, which houses the auditorium. The militants then burst into the building where a military team was conducting first-aid training for students between the ages of 14 and 16. Around 100 children were reportedly killed in the auditorium.
- 3. Pupils told how the gunmen then went from classroom to classroom, shooting children. According to witnesses, principal Tahira Qazi helped a number of children escape before she was killed when her office was hit by a suicide bomber.