Abdul Rashid Ghazi's body was found in the Red Mosque basement. Officials said he had been caught in the cross-fire.
The army says eight soldiers were also killed in the military operation, and about 50 women and children rescued.
Students at the mosque and its attached religious schools have waged a campaign for months pressing for Sharia law.
Public anger in the capital had been mounting after they kidnapped policemen as well as people they considered to be involved in immoral, un-Islamic activities.
"This is naked aggression. My martyrdom is certain now"
The BBC's M Ilyas Khan in Islamabad says the military operation is a gamble for President Pervez Musharraf who risks a backlash from supporters of those inside the mosque.
In recent days the army has redeployed thousands of troops in north-western Pakistan where pro-Taleban militants opposed to President Musharraf have been carrying out a string of attacks said to be linked to the mosque siege.
Troops attacked the mosque overnight and took control of most of the complex during heavy fighting which raged as they went from room to room throughout the day.
As darkness fell once more the gunfire died down, though sporadic explosions have been heard.
The military say the operation to take control of the mosque is in its final stages and will continue throughout Tuesday night.
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.
RED MOSQUE STAND-OFF
"He was spotted in the basement and asked to come out. He came out with four or five militants who kept on firing at security forces," Mr Cheema told AFP news agency.
"The troops responded and in the cross-fire he was killed."
Brig Cheema said Mr Ghazi had used a number of women and children as "human shields", although the cleric always denied taking anyone hostage.
Mr Ghazi was deputy leader of the Lal Masjid (Red Mosque). His brother, Maulana Abdul Aziz, who was head, was arrested trying to escape last week dressed in a burka.
Hours before his death, Mr Ghazi accused the authorities of "naked aggression".
"My martyrdom is certain now," he told Pakistan's Geo television station.
'Terrorists'
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.
HAVE YOUR SAY
One of the women rescued was said to be the wife of captured mosque leader Maulana Abdul Aziz.
Security forces began a full-scale siege of the 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.
Talks reportedly broke down over the militants' demand for an amnesty for all in the mosque.
The authorities said "hardcore terrorists" were inside the mosque, some belonging to Jaish-e-Mohammad, an outlawed radical Muslim organisation which has been linked to al-Qaeda.
Mr Ghazi denied the presence of any banned extremist groups. He said those inside were students of his religious school.
THE RED MOSQUE SIEGE
^ Back to top | BBC Sport Home | BBC Homepage | Contact us | Help | ©