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.

"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.

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.

FROM DEC. 17, 2014: First Video From Inside Peshawar School Shows Scale of Attack0:44

autoplay autoplay

Copy this code to your website or blog

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.