Four suspected attackers were killed in a battle that lasted nearly three hours.
Security forces continued to secure the campus, checking classrooms and dormitories, amid fears more bodies would be found.
There are conflicting reports about whether the Taliban militants carried out the assault
The group killed 130 students at a school in the city of Peshawar, 30 miles from Charsadda, in 2014.
About 3,000 students are enrolled at Bacha Khan but hundreds of visitors were also expected on January 20 for a poetry event.
Pakistani PM Nawaz Sharif said in a statement, quoted by Reuters news agency: “We are determined and resolved in our commitment to wipe out the menace of terrorism from our homeland.”
Attackers struck at around 09:30 local time, reportedly climbing over a back wall under cover of the thick winter fog.
Intense gunfire and explosions were heard as security guards fought the attackers.
Students and staff ran to find cover in toilets and examination halls.
Images from inside the university show a pool of blood on the floor of a dormitory and the charred corpses of two alleged militants lying on a staircase.
Nineteen bodies were taken to a local mortuary. It was not immediately clear if the attackers were among them.
A senior Taliban commander, Umar Mansoor, told media that the attack was in response to a military offensive against militant strongholds. He said four suicide attackers had carried out the attack.
The university is located in an open area some distance east of Charsadda town, surrounded by open agricultural fields.
Bacha Khan is a new university, founded in 2012, its website says.
Just days ago, some schools in Peshawar were closed by the authorities amid reports that militants were planning an attack.
The US House Ethics Committee has voted to release its report on former Republican Representative…
ABC News has agreed to pay $15 million to President-elect Donald Trump to settle a…
South Korea’s parliament has voted to impeach President Yoon Suk Yeol over his failed attempt…
Israeli war planes have carried out more than 100 air strikes in Syria on December…
President-elect Donald Trump has threatened to impose 100% tariffs on the BRICS countries if they…
Syrian troops have withdrawn from the city of Aleppo following an offensive by rebels opposed…