A spokeswomen for two hospitals in the city said they had received a total of nine bodies and were treating some 38 injured, including several in critical condition.
Police said at least three militants opened fire at security guards near the gates of the Agriculture Training Institute, injuring one of them before making their way inside and targeting the student accommodation.
Authorities said the gunmen had been killed and security forces had cleared the area after searching for remaining militants.
The 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.
Inter-Services Public Relations informed that two soldiers who were injured during the attack have been shifted to Combined Military Hospital for treatment.
Reports said Tehreek-e-Taliban Pakistan claimed responsibility for the attack.
Officials said the attack began at around 8am as loud expositions were heard and firing broke out at the institute's hostel opposite the Agricultural Directorate when at least three burqa-clad suspects entered the building.
Pakistani security officials inspect the scene of a terrorist attack at Peshawar University in Peshawar.
A wounded student, Ahteshan ul-Haq, told Reuters the university hostel usually houses almost 400 students, but most had gone home for a long holiday weekend and only about 120 students remained.
A gunbattle continued between forces and the attackers for over an hour and the Pakistan Army successfully killed all the terrorists. Aerial surveillance of the operation was carried out by the army aviation division whereas armoured vehicles of security forces were also called on site.
An eyewitness said, "We were sleeping when we heard gunshots". They are loosely allied with the Afghan Taliban insurgents.