The mosque is the result of continual construction, reconstruction, additions and renovations on the site from around 771 to the end of the 20th century.
The oldest part of the mosque is said to have been constructed by the orders of Harun al-Rashid. Later additions were made, the last being during the late Safavid era. The double layered main dome of the mosque is from the Seljuk era, and is locked to the public.