Government troops stormed the compound of Islamabad's Red Mosque before dawn Tuesday, prompting a fierce firefight with militants accused of holding scores of hostages, officials said. At least 40 rebels and three soldiers were killed.

Amid the sounds of rolling explosions, commandos attacked from three directions about 4 a.m. and quickly cleared the ground floor of the mosque, army spokesman Gen. Waheed Arshad said. Some 20 children who rushed toward the advancing troops were brought to safety, he said.

Well-trained militants armed with machine guns, rocket launchers and gasoline bombs put up tough resistance from the basement, Arshad said, adding rebels were also firing from minarets and have booby trapped some areas.

"Those who surrender will be arrested, but the others will be treated as combatants and killed," he said.

The assault began minutes after a delegation led by a former prime minister left the area declaring that efforts to negotiate a peaceful end to a week-old seige had failed.

Clashes this month between security forces and supporters of the mosque's hardline clerics prompted the siege. The religious extremists had been trying to impose Taliban-style morality in the capital through a six-month campaign of kidnappings and threats. Prior to Tuesday's assault, at least 24 people had been killed in and around the mosque.

The assault was signaled by blasts and gunfire. About three and a half hours after the assault started, Arshad said 50 to 60 percent of the complex had been "cleared" but resistance continued in "various places."

Some 40 militants had been killed and between 15 to 20 had been wounded. Arshad said three special forces commandos were also killed and 15 wounded.

Rebel leader Abdul Rashid Ghazi told the private Geo TV network that his mother had been wounded by gunshot. There was no immedidate official confirmation of his claim.

"The government is using full force. This is naked aggression," he said. "My martyrdom is certain now."

He said that about 30 militants were resisting security forces but were only armed with 14 AK-47 assault rifles.

As the fighting roiled on, emergency workers at an army cordon waiting for access to the compound. Women police officers were on standby to handle any female survivors or casualties.

A senior civilian official said troops had arrested dozens of people inside the compound and that part of the madrassa had caught fire. The official requested anonymity as he was not authorized to speak to media.

Tuesday attack followed a botched commando raid on the high-walled mosque compound over the weekend.

On Monday, President Gen. Pervez Musharraf assigned ex-premier Chaudhry Shujaat Hussain to try and negotiate a peaceful end to the standoff.

But Hussain and a delegation of Islamic clerics returned crestfallen from the mosque before dawn Tuesday after about nine hours of talks with rebel leader Abdul Rashid Ghazi via loudspeakers and cell phones.

"We offered him a lot, but he wasn't ready to come on our terms," Hussain told reporters waiting at the edge of the army cordon.

Several loud explosions boomed over the city just as the vexed looking delegates were getting into their cars and sporadic shooting was also heard.

About two dozen relatives of people trapped inside the complex waited anxiously at the army cordon during the assault.

The government has said wanted terrorists are organizing the defense of the mosque, while Ghazi has accused security forces of killing scores of students.

In his comments on Tuesday, Ghazi said he had offered to show the mediators that they had no heavy weapons, foreign militants or other wanted people inside the mosque.

The siege has given the neighborhood the look of a war zone, with troops manning machine guns behind sandbagged posts and from the top of armored vehicles.

It has also sparked anger in Pakistan's restive northwest frontier. On Monday, 20,000 tribesmen, including hundreds of masked militants wielding assault rifles, held a protest in the frontier region of Bajur.

Many chanted "Death to Musharraf" and "Death to America" in a rally led by Maulana Faqir Mohammed, a cleric wanted by authorities and who is suspected of ties to Al Qaeda No. 2 leader Ayman al-Zawahiri.

Click here for FOXNews.com's Asia center.