The mosque was built by the caliph Sulayman ibn Abd al-Malik in 715–717, but was completed by his successor Umar II by 720. The mosque itself was constructed of marble, while its courtyard was made of other local stone. Two hundred years later, Al-Muqaddasi described it as follows:
Reconstruction
An earthquake in January 1034 destroyed the mosque, "leaving it in a heap of ruins", along with a third of the city. In 1047, Nasir Khusraw reported that the mosque had been rebuilt. After the initial construction Ilyas Ibn Abd Allah supervised the second phase design of the western enclosure wall and the central ablutions building for Ṣalāḥ ad-Dīn Yūsuf ibn Ayyūb in 1190 CE. The third phase, in 1267–1268, began after the Crusader occupation was terminated. On the orders of the Mamluk sultan al-Zahir Baybars rededicated as a mosque and was modified by incorporating the dome, placing a new pulpit and prayer niche and adding the minaret. The sultanMuhammad al-Nasir Ibn Qalawun renovated the minaret after an earthquake in October 1318. The Mamluks commissioned restoration works in 1408.
Architecture
Much of the mosque was constructed in white marble with cypress and cedar wood used for the doors. It had four facades organized on a cardinal axis, of which the eastern one is in disrepair. The minaret was the north of the mosque structure, square in shape with five stories, each adorned with window niches, and a balcony towards the top. The minaret was probably influenced by Crusader design, but it was constructed by the Mamluks. The minaret is tall. There is speculation, however, that the minaret may have earlier been located closer to the center of the mosque as remnants of a square foundation have been found there. Although, this may have been just a fountain. The mosque also featured three underground cisterns with barrel-vaulted aisles below the central court. Under the courtyard of the mosque, the Abbasids, in 789 CE, under Haroun al-Rashid, constructed enormous cisterns for storage of water which remain intact to this day. Broad pilasters support the barrel-domed ceilings of the cisterns. They were filled with rainwater collected from the area around the mosque and with water carried by an aqueduct from the springs in the hills east of Ramla. The reservoirs provided water for the worshipers at the mosque and filled the pool for ablutions at the center of the courtyard, of which only the foundation remains today.
Archaeological excavations
Excavations conducted in 1949 on behalf of the Ministry of Religious Affairs and Israel Department of Antiquities and Museums revealed that the mosque enclosure was built in the form of a quadrangle and included the mosque itself; two porticoes along the quadrangle's east and west walls; the north wall; the minaret; an unidentified building in the center to the area; and three subterranean cisterns. The mosque was a broadhouse, with a qibla facing Mecca. Two inscriptions were found that mention repairs to the mosque. The first relates that Sultan Baybars built a dome over the minaret and added a door. The second inscription states that in 1408 CE Seif ed-Din Baighut ez-Zahiri had the walls of the southern cistern coated with plaster.