Afsharid dynasty
The mosque was built in 1765–1766 (AH 1179) by Hussein (Hoseyn) Ali Khan, the ruler of the Erivan Khanate under the Afsharid dynasty of Persia, as the city's main Friday mosque. The mosque underwent substantial redecoration with tiles around 1887-88 (AH 1305), under Russian administration. The mosque underwent another reconstruction in 1907–1910.