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.
Prosecutors and Donald Trump’s attorneys delivered opening statements and the first witness was called on…
The House of Representatives has finally approved $61 billion in new US military aid for…
The real estate market in the United States has always been a gauge for economic…
France's first lady Brigitte Macron will be the subject of a biopic series. Production company…
A first glimpse of the new business venture from Meghan Markle has been teased on…
Court has wrapped up for the first day of Donald Trump's long-awaited hush-money trial in…