Rescue workers are seen outside Bacha Khan University Reuters/Reuters TV

Twenty-one people, mostly teachers and students, were gunned down on Wednesday by militants at the Bacha Khan University in Charsadda, north-west Pakistan.

Seventeen others were injured in a siege that ended following a three-hour long battle with security forces. Four suspected attackers were killed before they could detonate their suicide vests after being cornered.

According to reports, eight to 10 civilian-clothed terrorists had gotten into campus grounds between 9 to 9.30am local time. The gunmen, many of them teenagers themselves, had climbed over a back wall and quickly engaged in a shoot-out with the university’s security guards.

Sounds of explosions and gunfire prompted staff and students to seek shelter in toilets and examination halls.

"We saw three terrorists shouting, 'God is great!' and rushing towards the stairs of our department,” one student is said to have told TV reporters.

"One student jumped out of the classroom through the window. We never saw him get up."

There are also reports that a chemistry lecturer saved his students by returning fire at the attackers with a pistol. He was eventually killed by two militants, said one witness, a Geology student.

People react outside Bacha Khan University Reuters/Reuters TV

Most of the victims were male, killed at a boys hostel located within the university.

"The attackers were like us -- they were very young,” a student told Pakistan publication, DawnNews. “They carried AK-47 guns. They wore jackets like the forces do.”

Classes were not in session at the university on Wednesday, but students were gathered at a ceremony commemorating the 28th anniversary of the death of an independent activist whose university is his name-sake.

A teacher (L) walks with a pair of crutches following her rescue Reuters/Fayaz Aziz

A Pakistani Taliban commander and mastermind of the 2014 Peshawar siege has claimed responsibility for the shooting. However, a spokesperson for the group later released a statement condemning the attack at Bacha Khan university, where 3,000 students are enrolled.

According to CNN counterterrorism analysts, the terrorist organisation very likely carried out the attack on Wednesday, despite conflicting statements that would have served a political purpose.

"We've seen consistent operations by the Taliban up in this area," CNN counterterrorism analyst Phil Mudd said. "I see this as simply as retaliatory, that is the Taliban saying, 'If you're going to bring Pakistani special forces and the army up into our turf, you're going pay a heavy price.”

Attacking students not uncommon

The Bacha Khan attack is not the first time an education institution has been targeted by the Therik-i-Taliban (TPP) – a faction of the Pakistani Taliban founded in 2007.

Just over a year ago, the group massacred 130 schoolchildren at a school in Peshawar, a city located just 50km from Charsadda. The December 2014 Peshawar attack – the country’s deadliest terrorist attack – drew international condemnation and ramped up military efforts to crack down on militants.

The TPP is also the group responsible for the 2012 assassination attempt on then 14-year-old Malala Yousaf, who was becoming increasingly recognised for speaking out about education rights.

"How dare the Taliban take away my basic right to education?" Yousaf once asked in a speech covered by media throughout the region.

RELATED: Malala Yousafzai Attackers Walk Free As Court Secretly Acquits Them

Malala eventually recovered from her injuries, and in 2014 was announced as a co-recipient of the Nobel Peace Prize. She is the youngest Nobel laureate to date.

Why does the Taliban target schools and children?

Although it may be easy to sweep the motivation behind these attacks under the rug, and focus instead on the actual carnage, the Taliban has been very specific about why it continues to target Pakistani youths.

“We are doing this because we want them to feel the pain of how terrible it is when your loved ones are killed," spokesman for the terror group Muhammad Khorasani said after the 2014 Peshawar siege.

The Peshawar school was an army-run educational facility, and its devastating attack carried out as an act of retaliation against military crackdown on the TPP.

In 2011, Taliban gunmen also killed four students on a schoolbus in Peshawar as a way of “punishing” local tribesmen for raising local militias to stop militant insurgency, AP reported.

“This was to teach them a lesson and we will continue to carry out attacks wherever and whenever possible no matter if it is a school or a school bus," said Mohammed Afridi, another Pakistani Taliban spokesman.

Soldiers gather outside Bacha Khan University in Charsadda, Pakistan, January 20, 2016. Reuters/Fayaz Aziz

Analysts believe targeting students is also a symbolic decision.

“They always justify their attacks by saying the Pakistani army is killing women and children,” editor of The Long War Journal, Bill Roggio, told FRONTLINE.

Moreover, education institutions and students are ‘easy targets’ for the terrorist group, especially after their ability to carry out large-scale attacks was dampened by the military crackdown.

“The TTP has been weakened, but retains the ability to carry out attacks like this [on schools],” Omar Hamid, head of global analytics firm HIS, told DW.

Wednesday’s Bacha Khan University attack, however, is expected to only strengthen the Army and government’s resolve to clamp down on the TPP.

"We are determined and resolved in our commitment to wipe out the menace of terrorism from our homeland," Prime Minister Nawaz Sharif said.

RELATED: Pakistan signs landmark defence deal with Russia, tries to find ‘US alternatives’ to terrorism problem