Pakistan Television quoted the Interior Ministry as saying that the radical cleric, Abdul Rashid Ghazi, was killed during the attack.
An army official said Ghazi had received bullet wounds and when he was told to surrender, he gave no reply. Commandos then fired another volley of bullets and found Ghazi dead, said the official, who spoke on condition of anonymity as he was not authorized to speak to media.
Javed Iqbal Cheema, spokesman for the Interior Ministry, confirmed Ghazi's death and said the cleric's body was still lying in the compound, and that "battle hardened" militants were defending themselves.
Ghazi's death could end almost a day of fierce fighting between his supporters and security forces, but could also spark a violent reaction from Pakistan's hardline Islamic groups, already at odds with the country's Western-backed president.
Commandos stormed the sprawling mosque compound before dawn. Twelve hours later, the army said the complex was 80 percent cleared of militants but it was still trying to root out well armed defenders the government accuses of holding a number of hostages. A local relief agency said the army asked for 400 white funeral shrouds.
The extremists had been using the mosque as a base to send out radicalized students to enforce their version of Islamic morality, including abducting alleged prostitutes and trying to "re-educate" them at the mosque.
Eight Pakistani soldiers also were killed, the army said.
Khalid Pervez, the city's top administrator, said earlier as many as 50 women had been freed by the militants and emerged from the complex, following the escape of 26 children. It wasn't clear if any hostages remained in the estimated 20 percent of the sprawling compound still under militant control.
Gunfire and explosions thundered over the city earlier in the day, as Army spokesman Gen. Waheed Arshad said more hostages were still being held.
"We are taking a step-by-step approach so there is no collateral damage," he told reporters. "We are fighting room by room." He added that stun grenades were being used to avoid casualties among the hostages.
Government officials said up to 70 blasts were heard in the first two hours of the pre-dawn operation led by members of the military's special forces, the SSG (Special Services Group), which began around 4:00 a.m. local time, reports CBS News' Farhan Bokhari.
After last-ditch efforts to negotiate a surrender failed, commandos attacked from three directions and quickly cleared the ground floor of the mosque, Arshad said. Some 20 children who rushed toward the advancing troops were brought to safety, he said.
In addition to the women, Arshad said about 50 suspected militants, some of them youngsters, had been captured or emerged from the mosque since the fighting erupted.
He said the entire compound included 75 rooms, large basements and expansive courtyards.
An officer, who demanded anonymity because he was not authorized to speak to the press, said earlier that troops had cornered Ghazi in the basement of the school, but held back from an all-out assault because a number of children were being held there as hostages.
Troops demanded four times that he surrender, but his followers responded with gunfire, and Ghazi said he was ready to die rather than give up, the officer said.