The mosque was built in 1865 by master craftsman Aga Muhammad Gulu oglu as a small takia (Dervish lodge). Later, in 1904, it was rebuilt and expanded into a fully fledged mosque by a villager named Haji Safarali. The mosque closed for worship in the 1930s and was turned into a grain store. The plot of land covers an area of 2,600 square metres, while the inner space is 320 square metres. The women’s prayer room is on the second floor.
Novkhani has much older mosques too, such as the 17th-century Shah Sultan Hussein Mosque, a well-preserved place of worship in the centre of the village. The Haji Safarali Mosque was built in the mid19th century, following a different architectural concept. The mosque was closed in Soviet times and was used as a grain store for a collective farm. The mosque eventually reopened for worship after Azerbaijan regained independence.
The mosque has been refurbished in accordance with the Absheron architectural traditions, plus two minarets have been erected. The area has been refurbished, all necessary technical issues have been resolved at a high level, the reconstruction was completed in 2007. Haji Safarali mosque complex is one of the most beautiful religious temples in Absheron.