A group of militants stormed the university, two of whom were killed by security forces after the army moved into the campus, Deputy Inspector General Saeed Wazir told Reuters. Other attackers were believed to be at large on the second and third floors of the campus buildings.
Three security guards, one university lecturer and one student were critically wounded but there were no confirmed deaths, Wazir said. He said 70 percent of students had been rescued.
Television channels quoted rescue officials as saying that a chemistry professor had been killed and 50 people wounded in the attack.
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.
"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," Wazir said.
He said it was unclear how many gunmen were involved.
The Pakistani military's media wing said the army had cordoned off the university with the militants inside and were carrying out air surveillance.
Television footage showed soldiers entering the campus as ambulances lined up outside the main gate and anxious parents consoled each other.
Pakistan, which has suffered from years of militant violence, has killed and arrested hundreds of suspected militants under a major crackdown launched after a massacre of 134 school children in December 2014 in the northwest.
The 2014 school attack by six gunmen believed linked to the Pakistani Taliban hit a raw nerve in Pakistan and was seen as having hardened Pakistan's resolve to fight jihadist militants along its lawless border with Afghanistan.
Vice Chancellor Fazal Rahim told reporters that the Bacha Khan University teaches over 3,000 students and hosted an additional 600 visitors on Wednesday for a poetry recital.
Shabir Khan, a lecturer in the English department, said he was about to leave the hostel 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."