Following the incident, a heavy contingent of police and Pakistan Army troops reached the site and cordoned off the area, besides sealing all roads leading to the directorate.
The army and local police who were summoned to the scene killed all the attackers, who arrived at the Agricultural Training Institute on Friday by rickshaw, the military's press wing said.
Bomb Disposal Squad Additional Inspector General Malik Shafqat said that the terrorists were wearing suicide jackets with ball bearings in them.
KP Governor Iqbal Zafar Jhagra said that the terrorists came prepared to stage a bigger attack than they were able to execute.
There were about 20 people including the students in the University as it had remained closed today due to Eid Miladun Nabi.
Generally, there are around 400 students at the hostel, but because of the holiday there were only 150 present.
It was not immediately clear how many people were wounded, with reports varying from at least five to 11 people. Mehsud said the terrorists had links inside Afghanistan.
An eyewitness said, "We were sleeping when we heard gunshots".
According to Hayatabad Medical Complex Director Shahzad Akbar, six dead and 18 injured were brought to the hospital. The Tehreek- i-Taliban Pakistan claimed responsibility for the attack.
"Our mujahids have attacked the building because it was used as office for ISI, God willing our fighters will fight till the last drop of blood", he said, referring to Pakistan's Inter Services Intelligence agency.
In December 2014, Pakistani Taliban gunmen killed 134 children at Peshawar's Army Public School, one of the single deadliest attacks in the country's history. Peshawar, close to the Afghan border, has seen some of the worst violence during the Taliban insurgency in recent years.