At least 50 people inside the Red Mosque and eight soldiers died during the operation, the military said.
The mosque's militant cleric, Abdul Rashid Ghazi, and some of his supporters were among those who died.
The mosque was besieged by troops for a week amid spiralling tension between radical students and the government.
Students at the mosque and its attached religious schools had waged a campaign for months pressing for the imposition of strict Islamic Sharia law.
It is not clear how many people were inside the complex when it was stormed.
In addition to those killed, about 70 militants had been captured or surrendered, the army said earlier.
"The first phase of the operation is over. There are no more militants left inside," army spokesman Maj Gen Washeed Arshad told the Associated Press news agency.
Pakistani Prime Minister Shaukat Aziz said no bodies of women or children had been found inside the mosque compound yet, AP reported.
The troops attacked the mosque on Tuesday morning and took control of the complex during heavy fighting as they went from room to room throughout the day.
Interior Ministry spokesman Javed Iqbal Cheema said Mr Ghazi was killed as troops were flushing out militants still inside a madrassa (religious school) for women and girls inside the mosque compound.
Security forces began a full-scale siege of the Red Mosque, or Lal Masjid, last Tuesday, not long after mosque students abducted seven Chinese workers they accused of running a brothel.
The government had said it wanted to detain a number of people on a wanted list, and also a number of foreigners whom it said were inside.