The militants climbed the back wall of Bacha Khan campus in Charsadda, northwestern Pakistan, at around 9:30am local time before opening fire on students and staff.
50 others were injured in the massacre.
Security guards and police needed hours to stop the attack, in which four militants also died.
It is uncertain who the terrorists are, but it's believed they're Taliban soldiers who targeted the university because it was holding a poetry gathering for its namesake, the late Bacha Khan, who opposed the Taliban in the 1980s.
There have been several terrorist attacks in northwestern Pakistan in recent years.
For example in 2013, the Taliban attacked a church in the city of Peshawar, around half an hour's drive from Charsadda, murdering 127 and injured around 250.
And in 2014 the extremists massacred 141 people, including 132 schoolchildren, at a school in Peshawar.
Today's attack prompted the student wing of a Pakistani Islamic group Jamaat-e-Islami to protest against the Taliban's violence.
Rt Revd Humphrey Peters, the Bishop of Peshawar, told Premier: "We are really sad about it and really don't know what to say about it except to pray and ask people to pray for us.
"We are under the terrible grip of terrorism.
"People who get injured they are really in a very bad condition. There will still people who were injured in the church attack, the people who were injured in the school attack - many of them are still on the beds.
"It becomes very difficult for them to survive, to live their life properly.
"So what we have said to everyone in the churches: please start praying. Especially for the bereaved families and especially the people who have lost their lives and people who are injured."
Listen to Premier's Aaron James speaking to Rt Revd Humphrey Peters here: