Four suspected attackers also died in a battle that lasted nearly three hours at Bacha Khan University in Charsadda.
One Pakistani Taliban commander said the group had carried out the assault, but its main spokesman denied this.
The group killed 130 students at a school in the city of Peshawar, 50km (30 miles) from Charsadda, in 2014.
Prime Minister Nawaz Sharif said in a statement: "We are determined and resolved in our commitment to wipe out the menace of terrorism from our homeland."
The attackers struck at around 09:30 local time (04:30 GMT), apparently climbing over a back wall under cover of the thick winter fog.