At least 59 cadets and guards have been killed in an attack by militants on a police college in the Pakistani city of Quetta.
Three militants wearing suicide bomb vests entered the college late on Monday, reportedly taking hostages.
A major security operation lasted for hours and all attackers were killed.
So-called Islamic State (IS) said its fighters had carried out the attack, although officials have blamed another militant group, Lashkar-e-Jhangvi.
Quetta, the capital of Balochistan province, has seen similar attacks by both separatists and various Islamist militant factions in recent years.
Hundreds of trainees were evacuated from Balochistan Police College as troops arrived to repel the militants. Local media reported at least three explosions at the scene.
“I saw three men in camouflage whose faces were hidden carrying Kalashnikovs.
“They started firing and entered the dormitory but I managed to escape over a wall,” one cadet said.
“The police academy is home to hundreds of students and many of the cadets who died were killed in the blasts,’’ Major General Sher Afghan of the Frontier Corps said.
The exact sequence of events is unclear but there was intermittent exchange of fire between the attackers and security forces for several hours, according to Dawn newspaper. There were also reports of a hostage situation.
More than 100 people, mostly trainees, were injured.
Pakistan’s army and the paramilitary Frontier Corps took part in the military counter-operation, which Balochistan provincial home minister Mir Sarfaraz Ahmed Bugti said was now over.
Two of the militants died after detonating their bomb vests and one was killed by security forces.
Officials blamed a faction of the Lashkar-e-Jhangvi militant group and said the attackers were in communication with operatives in Afghanistan.
However, IS said that its fighters had carried out the attack, releasing an image purported to be of the three gunmen.
IS formed a branch for Afghanistan and Pakistan in January 2015 under Hafiz Saeed Khan. He was killed in a US drone strike in July this year.
The first suspected IS attack in Pakistan was in April 2015, when three soldiers were killed. It then claimed an attack on a bus in Karachi that killed 45 people, although the Pakistani Taliban splinter group Jundullah also said it was responsible.
IS said it also carried out a suicide bombing that killed 88 people at a hospital in Quetta in August, but that too is disputed, with another faction of the Pakistani Taliban, Jamaat-ul-Ahrar, saying it was behind the attack.
Operation against militants
The Pakistani military has been conducting operations against militants in volatile tribal areas near the Afghan border.