"The operation is over. It was a good operation led by security forces, elite commandos, police and army units," Major General Athar Abbas, a military spokesman, said.
Al Jazeera's Kamal Hyder reported that as many as 800 people were believed to be in the police building when the attack began.
The attack on the academy also left 100 policemen wounded.
A security official said the police officers were preparing for training when the attack began.
Witnesses said that some of the attackers had entered the academy disguised as police officers.
"A grenade hit the platoon next to ours ... then there was continuous firing for about 20 minutes," one wounded police officer said.
"A man in light-coloured clothes - I think they were white - stood in front of us, firing at us. They wanted to do as much damage as possible."
The attackers reportedly hurled grenades at the police and TV footage showed several police officers bleeding and lying on the ground.
"It is a planned, organised, terrorist attack. This shows the extent to which the enemies of our country can go," Rehman Malik, the interior ministry chief, said.
"The question is - from where they are getting grenades, guns and rocket launchers in such a large number?" he said.
Imtiaz Gul, a Pakistani political analyst, said the attack underscored the "ill-preparedness" of police and paramilitary forces in the country.
"The kind of attack that took place is very, very difficult to pre-empt. There are people who came prepared to kill. On the other side, you see the kind of response from paramilitary forces.
"The entire country has been paying the price for this ill-preparedness," he said.
Pakistan has faced scores of attacks in recent years and, although Lahore has largely escaped the violence, it has not been immune.
Earlier in March, armed men brazenly ambushed Sri Lanka's cricket team in the city, killing six police officers and a driver, and wounding several of the players.
"The pattern is much the same; they are very well organised, very well co-ordinated and unfortunately very well executed as well," PJ Mir, a Pakistani political analyst, told Al Jazeera.
"The Americans have to put their foot down and provide the Pakistani forces with more up-to-date arms, more up-to-date technology to fight these elements of crimes."