The mosque was built over the tomb of the daughter of the seventh Shiite Imam - Musa al-Kadhim, who fled to Baku from persecution of Abbasid caliphs.
Arabic inscription on the mosque wall reads: "The work Mahmud ibn Sa'd", which is the same architect who built the Nardaran Fortress near Baku.
The mention of the mosque is also found in the works of local and European explorers and travelers, such as the Abbasgulu Bakikhanov, Ilya Berezin, Johannes Albrecht Bernhard Dorn, Nicholas Khanykov and Yevgeni Pakhomov.
In 1911, the patron of Baku, Alasgar Agha Dadashov with architect Haji Najaf constructed a new building of the mosque.
Bibi-Heybat Mosque, along with the Baku's Russian Orthodox Alexander Nevsky Cathedral and the Roman Catholic Church of the Immaculate Conception became a target for the new regime.
[1] In 1994, after Azerbaijan gained its independence, then president Heydar Aliyev ordered the construction of a new building for Bibi-Heybat Mosque at the same place where it was destroyed.
On the north side of the minaret and the mosque immediately adjoining the tomb, there was an inscription, which was discovered by Johannes Albrecht Bernhard Dorn.
On the inside the walls of marble carvings with calligraphic inscriptions such as muhaggah, Suls, Jami-Suls, Kufic, kufi-shatrandzh, musalsag, sofa and tugra.
Also widely used such ornamental compositions as islimi, shukyufa, Bandy-Rumi, zendzhiri Selcuk (Seljuk chain), Shamsi, Jafari and Achma-yumma.