A group of militants stormed a university in volatile northwestern Pakistan on Wednesday, killing at least 25 people as the army hunted for any gunmen still holed up on the campus, police said.
A security official said the death toll could rise to as high as 40 as the army cleared out student hostels and classrooms. A spokesman for the rescue workers said the dead included students, guards, policemen and at least one professor.
Firing had ended after several hours and four militants had been killed, the army said, in an attack that comes a little over a year after Taliban gunmen killed 134 students at a military-run school in nearby Peshawar.
The militants, using the cover of thick, wintry fog, scaled the walls of the Bacha Khan University in Charsadda, northwestern Khyber Pakhtunkhwa province, before entering buildings and opening fire on students and teachers in classrooms and hostels, police said.
The gunmen attacked as the university prepared to host a poetry recital on Wednesday afternoon to commemorate the death anniversary of Khan Abdul Ghaffar Khan, a popular ethnic Pashtun independence activist after whom the university is named.
Vice Chancellor Fazal Rahim told reporters that the university teaches over 3,000 students and was hosting an additional 600 visitors on Wednesday for the recital.
Police inspector Wazir said 70 per cent of students had been rescued.
"All students have been evacuated from the hostels, but militants are still hiding in different parts of the university and some students and staff are stuck inside," he said before the firing had stopped, adding that it was unclear how many gunmen were involved.
Television footage showed soldiers entering the campus as ambulances lined up outside the main gate and anxious parents consoled each other.
Shabir Khan, a lecturer in the English department, said he was about to leave his university housing for the department when firing began.
"Most of the students and staff were in classes when the firing began," Khan said. "I have no idea about what's going on but I heard one security official talking on the phone to someone and said many people had been killed and injured."
Pakistan, which has suffered from years of jihadist militant violence, has killed and arrested hundreds of suspected militants under a major crackdown launched after the massacre of school children in December 2014 in Peshawar.
The school attack by six Pakistani Taliban gunmen hit a raw nerve in Pakistan and was seen as having hardened Pakistan's resolve to fight militants along its lawless border with Afghanistan.
"We are determined and resolved in our commitment to wipe out the menace of terrorism from our homeland," Prime Minister Nawaz Sharif said in a statement after Wednesday's attack.