Pakistani police officer and rescue workers gather at the site of suicide bombing in Quetta, Pakistan, Wednesday, Jan. 13, 2016. The suicide attack on a polio vaccination center in southwestern Pakistan killed more than a dozen people and wounded many, ... more >

QUETTA, Pakistan (AP) - Survivors of an overnight attack that killed 61 people at a Pakistani police academy described chaotic scenes of gunfire and explosions, with militants shooting anyone they saw and cadets running for their lives and jumping from windows and rooftops.

A Taliban splinter group and an affiliate of the Islamic State group made competing claims of responsibility for the four-hour siege late Monday at the Police Training College on the outskirts of the southwestern city of Quetta.

Most of the dead and the 123 wounded were recruits and cadets, said Wasay Khan, a spokesman for the paramilitary Frontier Corps. Of the three militants who carried out the attack, two blew themselves up with explosive vests and the third was killed by army gunfire, he added.

As the nation reeled and sought to understand how militants were able to carry out such violence, many Pakistanis were reminded of a bloody 2014 attack by the Taliban on an army-run school in Peshawar in which more than 150 people, mostly children, were killed.

Broadcasters on Tuesday showed the aftermath of the attack on the Quetta academy: scorched windows and floors littered with the shoes of the dead and wounded.

Prime Minister Nawaz Sharif and the army chief Gen. Raheel Sharif rushed to the scene to meet with survivors, who spoke of the horrors of the surprise attack on about 700 cadets, trainees, instructors and other staff that began about 11:30 p.m.

Cadet Asif Hussain said he had been asleep when gunshots broke out.

“We hid ourselves beneath cots. We had in our mind that if we didn’t lock ourselves inside the hall, they will kill us,” he said.

The attackers kicked at their door but failed to open it, Hussain said. The gunmen instead fired on them from a window, wounding two cadets before moving to a nearby dorm.

Shortly after entering, one of the attackers detonated his vest inside a hall after firing at cadets.

In the chaos, cadets and trainers ran for their lives, jumping through windows and off rooftops to try to escape.

Troops arrived and “it gave us confidence that we are safe now,” Hussain said.

Another recruit, his face covered in blood, told a TV station that the gunmen shot at anyone they saw.

“I ran away, just praying God might save me,” he said.

Another witness, Faisal Khan, said he had been chatting with friends when the shooting began.

“We closed the main door and switched off lights,” he said.

While most of the casualties were from the academy, some of the soldiers who responded to the assault also were killed, said Shahzada Farhat, a police spokesman in Quetta, the capital of Baluchistan province.

The Islamic State group posted a claim of responsibility on the group’s media arm, the Arabic-language Aamaq news agency. The claim was not confirmed by Pakistani officials and IS did not offer any previously unknown details about the attack.

A little-known breakaway faction of the Pakistani Taliban, called the Hakimullah group, also claimed responsibility.

In addition, Maj. Gen. Sher Afgan, head of the Pakistani paramilitary force that is primarily responsible for Baluchistan province, said the attackers had received instructions from commanders in neighboring Afghanistan and were most likely from the banned militant group Lashker-e-Jhangvi Al-Almi, which is affiliated with al-Qaida and the Taliban. The Sunni militant group has mainly targeted minority Shiite Muslims whom its members consider to be infidels.

Pakistani officials said they had received intelligence reports that militants had entered Baluchistan province, but there was no indication of possible targets.

Earlier, Interior Minister Chaudhry Nisar Ali Khan, without naming Afghanistan, said enemies of Pakistan were planning attacks in Pakistan from a neighboring country.

Kabul condemned the attack and dismissed the allegations that the assault was planned from bases inside Afghanistan.

“Afghanistan is the biggest victim of terrorism and denounces all terrorist attacks,” said Mohammad Haroon Chakhansuri, spokesman for Afghan President Ashraf Ghani.

Ghani himself also condemned the attack, saying, “Terrorism is a threat throughout the region, which is reflected in the brutal act today in Quetta.”

Pakistan maintains that militants fleeing army operations in its tribal regions regularly flee over the border and find safe haven in Afghanistan. For his part, Ghani has criticized Pakistan, saying it has provided shelter to the Taliban, and in particular, the violent Haqqani network.

For over a decade, Baluchistan has been the scene of a low-intensity insurgency by nationalist and separatist groups demanding a bigger share in the regional resources.

Pakistan has carried out several military operations against militants in its lawless tribal regions near Afghanistan, including a major push that began in mid-2014 in North Waziristan, a militant base. The militants have killed tens of thousands of people, seeking to install their own harsh brand of Islamic law.

Later Tuesday, the flag-draped coffins of the slain cadets and troops began being moved from Quetta to their families for burial.

One of the dead, army Capt. Rooh Ullah, was given Pakistan’s fourth-highest military award for killing one of the militants before he was slain. Sharif, the army chief, attended a service for him in Quetta before the body was flown to his hometown in the northwest.

Ullah’s father told a local TV station that he was proud his son died a “martyr.”

In Islamabad, minority Christians lit candles for those killed. They chanted slogans condemning violence and vowing to support the victims.