This mosque, which was known as the Khazina library under the Soviets, was built by two Iranian workmen at the expense of the local people in 1880. It is an ancient sample of oriental architecture. This building was in fact constructed on top of an Albanian historical monument which belongs to the pre-Islamic period. In the early days of Islam, the temple operated as a centre inviting to Islam. Under Caliph Umar ibn Khattab, its scope of operation was even broader. As a result of Islamic propaganda in Azerbaijan, some Albanians adopted Islam. At that time, local Albanians rebuilt the Christian temple and turned it into a mosque. It used to have a five or six meter high roof.