The Taliban claimed responsibility for an attack by multiple gunmen that killed at least 20 people at a university in northwestern Pakistan Wednesday morning.
In addition to the victims, Pakistan police said four attackers had been killed at Bacha Khan University in the town of Charsadda, located 21 miles outside the city of Peshawar.
Provincial governor Sardar Mehtab Abbasi said the attack is now over and that the troops have cleared the campus.
Taliban leader Khalifa Umar Mansoor told AFP: "Our four suicide attackers carried out the attack on Bacha Khan University today." Mansoor said the attack was in retaliation for a military offensive against extremists in tribal areas near the border with Afghanistan.
Mansoor was the mastermind behind the December 2014 attack on an army-run school that killed over 150 people, 144 of them children.
But the main spokesman for the Pakistani Taliban, Mohammad Khurasani, said the attack was "un-Islamic" and insisted the Pakistani Taliban were not behind it. Such statements from among the Taliban are not uncommon since the group has many loosely linked factions.
The absence of the overall leader of the Pakistani Taliban, Mullah Fazlullah, who is believed to be hiding in Afghanistan, means that local commanders often operate independently.
The spokesman also said the Taliban "consider the students in non-military institutions the future of our jihad movement" and would not kill potential future followers. He insisted Fazlullah had nothing to do with the assault.
Khurasani said those who carry out such attacks should be tried before an Islamic, or Sharia court.
The militants, wielding AK-47s, used the cover of thick, wintry fog to scale the campus walls. They then went into university buildings and opened fire on teachers and students as classes began.
Explosions were heard inside and Pakistani TV stations aired images of heavily armed security personnel entering the compounds as female students ran for their lives.
At the university gates, distraught relatives of those being taught inside anxiously waited for news.
Regional police chief Saeed Wazir said most of the victims were killed at a hostel for male students inside the campus.
Lt. Gen. Asim Bajwa, an army spokesman, said 18 students and two teachers were killed.
Witnesses identified one of the teachers killed as a chemistry professor named Dr. Hamid who tried to return fire at the attackers.
"He was holding a pistol in his hand," Geology student Zahoor Ahmed told Sky News. "Then I saw a bullet hit him. I saw two militants were firing. I ran inside and then managed to flee by jumping over the back wall."
Another student told TV reporters: "We saw three terrorists shouting, 'Allah is great!' and rushing towards the stairs of our department. One student jumped out of the classroom through the window. We never saw him get up."
Botany teacher Mohammad Ishtiaq said he saw five gunmen enter the building he was in and begin firing automatic assault rifles, as students ran in all directions. He said he locked himself inside a second-floor bathroom and then jumped out the window when he saw one of the attackers approaching. He broke his leg in the fall.
After the attack, Pakistani army chief Gen. Raheel Sharif visited the university and the wounded in hospital.
The Bacha Khan University is named after the founder of a liberal, anti-Taliban political party. The Pakistani Taliban has targeted the party in the past for its anti-militant policies.
More than 3,000 students are enrolled at the school, which was hosting an extra 600 visitors on Wednesday for a poetry recital, Vice Chancellor Fazal Rahim said, according to Sky News.
In a statement released after Wednesday's attack, Pakistani Prime Minister Nawaz Sharif said "we are determined and resolved in our commitment to wipe out the menace of terrorism from our homeland."
Pakistan vowed to redouble efforts to combat militants after the 2014 Peshawar school attack, lifting a moratorium on the death penalty and intensifying a military offensive in North Waziristan, a tribal region and longtime stronghold of the Taliban and other militants.
Last month, as the country marked the anniversary of the school attack, the military claimed "phenomenal successes" in the war and said it had killed around 3,500 insurgents since launching the operation in 2014.
The Associated Press contributed to this report.