CHARSADDA, Pakistan/ISLAMABAD, Jan 20 (Reuters) - Armed militants stormed a university in volatile northwestern Pakistan on Wednesday, killing at least 20 people and wounding dozens a little more than a year after the massacre of 134 students at a school in the area, officials said.
A senior Pakistani Taliban commander claimed responsibility for the assault in Khyber Pakhtunkhwa province, but an official spokesman later denied involvement, calling the attack "un-Islamic."
The violence nevertheless shows that militants retain the ability to launch attacks, despite a country-wide anti-terrorism crackdown and a military campaign against their strongholds along the lawless border with Afghanistan.
A security official said the death toll could rise to as high as 40 at Bacha Khan University in the city of Charsadda. The army said it had concluded operations to clear the campus six hours after the attack began, and that four gunmen were dead.
A spokesman for rescue workers, Bilal Ahmad Faizi, said 19 bodies had been recovered including students, guards, policemen and at least one teacher, named by media as chemistry professor Syed Hamid Husain. Husain reportedly shot back at the gunmen with a pistol to allow his students to flee.
Many of the dead were apparently shot in the head execution-style, TV footage showed.
The militants, using the cover of thick, wintry fog, scaled the walls of the university on Wednesday morning before entering buildings and opening fire on students and teachers in classrooms and hostels, police said.
See photos from the scene:
Students told media they saw several young men wielding AK-47 guns storming the university housing where many students were sleeping.
"They came from behind and there was a big commotion," an unnamed male student told a news channel from a hospital bed in Charsadda's District Hospital. "We were told by teachers to leave immediately. Some people hid in bathrooms."
Thirty five of the wounded remain in hospital, a local police official said late on Wednesday.
The gunmen attacked as the university prepared to host a poetry recital on Wednesday afternoon to commemorate the death anniversary of Khan Abdul Ghaffar Khan, a popular ethnic Pashtun independence activist after whom the university is named.
Vice Chancellor Fazal Rahim told reporters that the university teaches over 3,000 students and was hosting an additional 600 visitors for the poetry recital.
Umar Mansoor, a senior Pakistani Taliban commander involved in the December 2014 attack on the army school in Peshawar, claimed responsibility for the Charsadda assault and said it involved four of his men.
He told Reuters by telephone the university was targeted because it was a government institution that supported the army.
However, later in the day, official Taliban spokesman Muhammad Khorasani issued a written statement disassociating the militants from the attack, calling it un-Islamic.
"Youth who are studying in non-military institutions, we consider them as builders of the future nation and we consider their safety and protection our duty," the statement said.
The reason for the conflicting claims was not immediately clear. While the Taliban leadership is fractured, Mansoor is believed to remain loyal to central leader Mullah Fazlullah.
The Pakistani Taliban are fighting to topple the government and install a strict interpretation of Islamic law. They are loosely allied with the Afghan Taliban who ruled most of Afghanistan until they were overthrown by U.S.-backed military action in 2001.
By afternoon on Wednesday, the military said all four gunmen had been killed.
"The operation is over and the university has been cleared," Pakistan army spokesman General Asim Bajwa said.
A security official close to the operation said he had seen the four gunmen's bodies riddled with bullets. He said none of the gunmen was wearing a suicide vest, but they carried guns and grenades.
RUMOURS OF ATTACK
Television footage showed military vehicles packed with soldiers driving into the campus as helicopters buzzed overhead and ambulances lined up outside the main gate while anxious parents consoled each other.
Shabir Khan, a lecturer in the English department, said he was about to leave his university housing for the department when firing began.
"Most of the students and staff were in classes when the firing began," Khan said.
Several schools had closed early at the weekend around Peshawar, the capital of Khyber Pakhtunkhwa, after rumors circulated of a possible attack.
The area has been on edge since the December 2014 massacre by six gunmen in Peshawar.
Pakistan, which has suffered from years of jihadist militant violence, has killed and arrested hundreds of suspected militants under a major crackdown launched afterwards.
The Peshawar school attack was seen as having hardened Pakistan's resolve to fight militants along its lawless border with Afghanistan.
"We are determined and resolved in our commitment to wipe out the menace of terrorism from our homeland," Prime Minister Nawaz Sharif said in a statement after Wednesday's attack.
More from AOL.com:
Penguin Random House takes degree requirements off job applications
Sarah Palin's oldest son arrested in domestic violence case
Ben Carson cancels campaign events after staffer dies in car crash