CHARSADDA, Pakistan: Militants stormed a university in northwestern Pakistan on Wednesday, killing at least 20 people and triggering an hours-long gunbattle with security forces in an attack that echoed a horrifying assault by the Taliban a little over a year ago on a nearby army-run school.

The attack began shortly after classes started at the Bacha Khan University in Charsadda, a town 35 km outside Peshawar, said Deputy Commissioner Tahir Zafar. The school may have been targeted because it is named for a late secular icon.

The attackers climbed over the back walls of the university and shot at a security guard before making their way to the administration building and the male students’ dorms, police official Saeed Khan Wazir said.

Soldiers and police raced to the scene and exchanged fire with the attackers. The sound of gunfire and explosions echoed across the campus. Troops later cornered the attackers inside two university blocks, killing all four of them, the army said.

Lt. Gen. Asim Bajwa, the army spokesman, said 18 students and two teachers were killed.

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.

A Taliban leader, Khalifa Umar Mansoor, claimed responsibility for Wednesday’s attack in a phone call from an undisclosed location. Mansoor, who masterminded the Peshawar school attack, said a four-man Taliban team carried out the latest assault. He said it was in revenge for scores of militants killed by Pakistani security forces in recent months, and that the university was attacked because it was “an instrument of the government and army.”

However, a spokesman for the main Taliban faction in Pakistan later disowned the group behind Wednesday’s attack, describing the assault as “un-Islamic.”