Qom is the second most sacred city in Iran after Mashhad. Much of the shrine complex was first built by Shah Abbas I in the early 17th century.

Qom, along with the shrine were raided in 1221 by the Mongols and again by the Tamerlane. In 1519 the dome of the shrine was rebuilt and the courtyard was embellished in honour of the Safavid king, Shah Ismail I.