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.