Pakistani security forces have recaptured a police academy after eight hours of clashes with gunmen who seized the complex during a morning drill.
Military helicopters opened fire on the compound near Lahore as troops entered to confront grenade-throwing militants.
Pakistan's Interior Ministry said 18 people had been killed, including eight policemen and eight militants. Other reports put the death toll higher.
Nearly 100 people have been injured, the ministry adds.
The assault comes less than a month after gunmen attacked the Sri Lankan cricket team in Lahore, killing six policemen. Those gunmen escaped.
Chaotic scenes
The siege at the Manawan police training school on the outskirts of Lahore ended at around 1600 local time (1100GMT) after sustained heavy gunfire lasting 10-15 minutes.
Jill McGivering reports from outside the academy near Lahore
This was a well-organised attack that will raise concern about the sophistication of the group behind it.
Pakistan is facing a broad insurgency from groups linked to al-Qaeda, the Afghan Taleban and the Pakistani Taleban, as well as from religious extremists and criminals taking advantage of the situation.
It is unclear who was responsible for this attack, but its co-ordinated nature could point to one of the more international groups.
Military helicopters swooped low, firing directly into the training school.
As paramilitary forces tried to force their way into the main building, the gunmen retaliated by throwing grenades.
Roads around the site were clogged with vehicles and people.
Paramilitary troops were seen celebrating on the roof of the compound after the siege had ended.
The BBC's Damian Grammaticas, who has since been into the police academy, said rescue teams with masks were carrying out bodies under white sheets.
He described the scene there as chaotic, with broken glass, bullet casings and pieces of human flesh scattered over the floor.
'Planned attack'
The gunmen attacked from four sides, while trainee police were doing their morning drill on the academy's parade ground, officials and witnesses said.
They threw grenades before opening fire, and at least some of the gunmen were said to be disguised in police uniforms.
Elite troops were called in to retake the area.
MAJOR PAKISTAN ATTACKS
27 March 09: Suicide bomber demolishes crowded mosque near the north-western town of Jamrud, killing dozens.
3 March 09: Six policemen and a driver killed, and several cricketers injured, in ambush on the Sri Lanka cricket team in central Lahore
20 Sept 08: 54 die in an attack on the Marriott hotel in Islamabad
6 Sept 08: Suicide car bombing kills 35 and wounds 80 at a police checkpoint in Peshawar
Aug 08: Twin suicide bombings at gates of a weapons factory in town of Wah leave 67 dead
March 08: Suicide bombs hit police headquarters and suburban house in Lahore, killing 24
Interior Ministry chief Rehman Malik increased the death toll from 14 to 18, with a further four militants confirmed dead.
Two civilians had died, along with eight policemen and eight militants, and 95 people had been injured, he said.
The military has put the death toll at 27.
At least two of the attackers are believed to have blown themselves up.
Mr Malik called the assault a "planned, organised, terrorist attack".
"This shows the extent to which the enemies of our country can go," he told the local Geo TV station.
But he added: "It is wrong to say that law and order has collapsed in Pakistan.
"We are very near to [tracing] the attackers involved in this."
No group has yet claimed responsibility for the attack, but it comes days after US President Barack Obama pledged to put Pakistan, along with Afghanistan, at the heart of his fight against al-Qaeda militants.
He said "al-Qaeda and its extremist allies are a cancer that risks killing Pakistan from within."
US officials have pledged to help Pakistan target so-called "safe havens" for militants in Pakistan's north-west tribal region bordering Afghanistan.
Bookmark with:
What are these?