The three heavily armed militants, who arrived on an auto rickshaw, attacked the students' hostel of the Directorate of Agriculture Extension on the University Road in the city, the capital of the restive Khyber-Pakhtunkhwa province.
The institute was closed for the Eid-e-Milad holiday, but about 70 students were present in the hostel.
The militants stormed the building by firing automatic weapons, creating panic, officials said.
Police chief of Khyber Pakhtunkhwa province Salahuddin Mehsud said12 people including six students, a security guard and five civilians, were killed and 32 others injured in the attack.
Also Read
Aerial surveillance of the operation was carried out by the army aviation division whereas armoured vehicles of security forces were also called on site.
He said three terrorists were killed by security forces after a gunfight which lasted for an hour. Police are trying to ascertain the identity of a dead person.
Bullets holes in building walls, broken glass scattered and blood stains could be seen on TV footage.
A police officer and two army troops were among the injured.
Mehsud said the terrorists had links inside Afghanistan.
An eyewitness said he and his colleagues were sleeping when the firing started Geo News reported.
The eyewitness, a student, said he and his colleagues ran as fast as they could but two of them were injured in the firing.
"We took them out with us and admitted them to the hospital," said Ariful Haq, adding that around 120 students live in the hostel but most had gone home due to the long weekend.
Peshawar, close to the Afghan border, has seen some of the worst violence during the Taliban insurgency in recent years.
In 2014, a total of 147 people, including 132 schoolchildren, were massacred in one of the deadliest terrorist attacks in the countrys history when terrorists stormed the Army Public School in Peshawar Cantonment and opened indiscriminate fire.
Later, on January 20, 2016, 21 students and staff members of Bacha Khan University in Charsadda here were killed after terrorists stormed the university and opened fire.
Disclaimer: No Business Standard Journalist was involved in creation of this content