Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

CHARSADDA, Pakistan — Militants using heavy fog as cover stormed a Pakistani university early Wednesday, killing some 20 people and injuring around 60 others, many of them critically.

Yelling "Allahu Akbar" ("God is great") and brandishing AK-47 rifles, the quartet of gunmen struck classrooms and dorms at the Bacha Khan University in Charsadda, killing some of the victims execution-style with a shot to the head, police and witnesses said.

"There was heavy fog in the area when armed men entered ... and started firing at the security guards, students and teachers" regional police chief Saeed Wazir told NBC News.

Wazir said the attack appeared to be well-planned because "they knew where to go and they knew who to go for."

All four were wearing explosives vests but only one of them was able to detonate his deadly payload, police said. The rest died in a fierce gun battled with Pakistani military and at least two appeared to be teenagers.

“Within 45 minutes forces were active and the attackers contained," military spokesman Lt. Gen. Asim Salim Bajwa said.

In the aftermath, NBC News reporters toured the men's dormitory and saw blood of the floors and the walls pitted by bullets. Much of the two-story building was destroyed.

Charsadda Update:clearance of university block by block continues by Army troops.No firing being heard — AsimBajwa (@AsimBajwaISPR) January 20, 2016

A survivor, Mohammed Shabir, who lives in one of the university's dorms, said he hid in the bathroom for at least two hours as the militants struck.

The Morning Rundown Get a head start on the morning's top stories. This site is protected by recaptcha

"We could hear their movements but couldn't see them because of the dense fog," the English teacher said.

The gunmen shot one of Shabir's roommates in the head and face, killing him.

"I'm happy I'm alive but my roommate, a brilliant professor, died too young," the 28-year-old said.

Student Bakhtiar Khan told how he witnessed a gunbattle.

"They shot [and] injured three security guards and one of them later went to block number one, another climbed to upper floor of the building and the third one went towards administration block," he said.

Bacha Khan University is named after Khan Abdul Ghaffar Khan, a prominent progressive politician and champion of women's rights. Wednesday is the anniversary of his 1988 death.

Photos: Shock and Grief After Gunmen Storm University

Vice Chancellor Fazle Rahim Marwat said 3,000 students are enrolled at the university. There were more people than usual on campus on Wednesday because the school was holding a poetry symposium to honor Khan, professors told NBC News.

Authorities in Pakistan's violence-torn northwest had been warned about the possibility of an attack about two weeks ago and had increased security at the site, an official said speaking on condition of anonymity told NBC News.

Pakistan's Prime Minister Nawaz Sharif was "personally monitoring the situation" in Charsadda, according to a statement issued by his office.

Survivors and rescuers carry the body of a victim of a deadly attack on Bacha Khan University in Charsadda, Pakistan, on Wednesday. BILAWAL ARBAB / EPA

"We are determined and resolved in our commitment to wipe out the menace of terrorism from our homeland," he said in the statement. Sharif was attending the World Economic Forum (WEF), the annual gathering of world business and political leaders in Davos, Switzerland.

While a Taliban commander initially claimed responsibility for the attack, a spokesman for the group later denied the militants had been involved.

"This is a reaction to extrajudicial killing of our people by the Pakistani security agencies,” Khalifa Omar Mansour, the head of the Pakistani Taliban's (TTP) military wing, told NBC News over the telephone as he took responsibility for directing the siege.

According to the Taliban, Mansour directed the December 2014 attack on the Army Public School in Peshawar that left 143 students and several soldiers dead. Peshawar is some 20 miles south of Bacha Khan University.

However, Muhammad Khurasani, a spokesman for the TTP, said in a statement on Facebook that the group "strongly" condemned the attack, calling it a "heinous act."

The militant group is riven with divisions since its spokesman and a handful of commanders pledged allegiance to ISIS in 2014, according to Alex Kassirer of global security firm and NBC News consultant Flashpoint Intelligence.