The Juma mosque of Shamakhy (Şamaxı Cümə Məscidi in Azerbaijani) was initially built in 743 AD. Over time it was seriously damaged and reconstructed a number of times. In 1859 and 1902 it was again damaged by earthquakes. During the march genocide of 1918 Armenian nationalists set the mosque on fire. The mosque was extensively restored and rebuilt in 2010-2013 under president Ilham Aliyev.