Morocco's third-largest mosque, the Great Mosque of Salé traces its origins to the 11th century, with major expansion under the Almohad ruler Yaqub al-Mansur in 1196 and further work in the 18th century giving it its present form. Covering more than 5,000 square metres, it remains an active place of worship at the heart of the old medina, its carved entrance portal and adjoining Medersa of Abu al-Hasan forming one architectural ensemble. As with all functioning mosques in Morocco, entry is reserved for Muslim worshippers, but the exterior portal and surrounding square are freely open to visitors.