However the building was destroyed by the Ottoman ruler Murad IV after invading Tabriz in 1638. Once Persian troops re-affirmed control over the city, the mosque was rebuilt but suffered great damage from an earthquake that struck the city soon after.
Consequently, the entire square along with the mosque was reconstructed and this task was carried out by Goli Khan Danbali. In favor of the people, the mosque was dubbed Saheb ol Amr, a title of the last Twelver Shi'a Imam, Muhammad al-Mahdi. in 1850, Mirza Ali Akbar Khan, who was the Russian Consulate interpreter, rebuilt some other parts of dome, and added mirrors to the corridor. A school was built in the front part of the dome during the next phase.