The site of the mosque is believed to have originally been the site of a Roman temple dedicated to Hercules and of a 5th-century Roman church.
A grand mosque (Friday mosque) was established on this site during the Marinid dynasty (13th-15th centuries).
Tangier was frequently besieged by European forces in the 15th century until it was finally conquered by the Portuguese in 1471.
The Portuguese immediately converted the mosque or rebuilt the site into a cathedral.
In 1662 Tangier was passed to the English as part of Catherine of Braganza's dowry to Charles II.
After years under pressure from local Muslim mujahidin attacks, the English evacuated Tangier in 1684, blowing up its fortifications before leaving.
The sultan of Morocco at the time, Moulay Ismail from the Alaouite dynasty, immediately claimed the city and supported its Muslim resettlement (including by many of the mujahidin who had fought against the European presence).
The Muslim settlers immediately sought to pray in the cathedral which had formerly been the grand mosque.
Moulay Ismail ordered the new governor, Ali ibn Abdallah Errifi, to convert the building to a mosque.

The new mosque, however, was reportedly very crude, despite being an important symbol of the city's return to Muslim rule.
Muslim travelers commented on its poor amenities.
The Alaouite Sultan Moulay Slimane was reportedly so shocked by its condition upon seeing it in 1815 that he immediately ordered that it be completely rebuilt.
Artisans from outside Tangier were recruited to help with the task, and the reconstruction was completed in 1817-18.
The mosque's current form dates essentially from this construction.
Subsequent Alaouite sultans continued to embellish or restore the mosque, reinforcing its role as a symbol of the government's importance in upholding religious orthodoxy in the face of other popular forms of religion focused around Sufi marabouts.
Along with the khutba, the weekly Friday sermon, important official announcements were also delivered here.

The mosque was also a focus of civic life and urban infrastructure.
It was located near the Inner Market (formerly the Roman Forum), following a pattern found in other Moroccan and Islamic cities where the most important or prestigious commercial activities took place near the city's main mosque.
Across the street on the southwest side of the mosque was the house of the qadi, or judge, where legal cases were heard and resolved.
Next to this was the house of the muwaqqit, the timekeeper of the mosque (i.e. responsible for accurately determining the time of prayers), which was connected to the mosque itself by an overhead passage between the house and the minaret.
Further south on the same street was a cistern, a maristan or hospital dedicated to caring for the mentally ill, and a house for washing the bodies of the dead (especially for foreigners who died far from home, given Tangier's role as a port).
On the mosque's northwestern side, across the street from its main entrance, was a madrasa (school) built in the 18th century under sultan Muhammad ibn 'Abdallah.
Attached directly to the mosque itself, behind its southeastern wall (the qibla wall), was a library and a funeral mosque (jama' al-gna'iz, where funerary rites where performed before the body's burial).
Some of these amenities were managed and funded by the habous (or waqf) of the mosque; that is, a charitable trust under which the mosque drew revenues from various sources for its upkeep and the upkeep of its associated establishments.

In the decades prior to colonial rule and the establishment of an international (European) regime governing Tangier (between 1924 and 1956), the mosque's civic importance declined and the fiscal assets of its habous were increasingly confiscated or diverted by the government.
Under colonial rule all habous establishments were further curtailed and lost their role as agents of urban development.
Like in many other North African cities, a Ville Nouvelle ("New City") was established outside the old city walls and rapidly outgrew it, thus reducing th
The site of the mosque is believed to have originally been the site of a Roman temple dedicated to Hercules and of a 5th-century Roman church. A grand mosque (Friday mosque) was established on this site during the Marinid dynasty (13th-15th centuries). Tangier was frequently besieged by European forces in the 15th century until it was finally conquered by the Portuguese in 1471. The Portuguese immediately converted the mosque or rebuilt the site into a cathedral. In 1662 Tangier was passed to the English as part of Catherine of Braganza's dowry to Charles II. After years under pressure from local Muslim mujahidin attacks, the English evacuated Tangier in 1684, blowing up its fortifications before leaving. The sultan of Morocco at the time, Moulay Ismail from the Alaouite dynasty, immediately claimed the city and supported its Muslim resettlement (including by many of the mujahidin who had fought against the European presence). The Muslim settlers immediately sought to pray in the cathedral which had formerly been the grand mosque. Moulay Ismail ordered the new governor, Ali ibn Abdallah Errifi, to convert the building to a mosque.
The new mosque, however, was reportedly very crude, despite being an important symbol of the city's return to Muslim rule. Muslim travelers commented on its poor amenities. The Alaouite Sultan Moulay Slimane was reportedly so shocked by its condition upon seeing it in 1815 that he immediately ordered that it be completely rebuilt. Artisans from outside Tangier were recruited to help with the task, and the reconstruction was completed in 1817-18. The mosque's current form dates essentially from this construction. Subsequent Alaouite sultans continued to embellish or restore the mosque, reinforcing its role as a symbol of the government's importance in upholding religious orthodoxy in the face of other popular forms of religion focused around Sufi marabouts. Along with the khutba, the weekly Friday sermon, important official announcements were also delivered here. 
The mosque was also a focus of civic life and urban infrastructure. It was located near the Inner Market (formerly the Roman Forum), following a pattern found in other Moroccan and Islamic cities where the most important or prestigious commercial activities took place near the city's main mosque. Across the street on the southwest side of the mosque was the house of the qadi, or judge, where legal cases were heard and resolved. Next to this was the house of the muwaqqit, the timekeeper of the mosque (i.e. responsible for accurately determining the time of prayers), which was connected to the mosque itself by an overhead passage between the house and the minaret. Further south on the same street was a cistern, a maristan or hospital dedicated to caring for the mentally ill, and a house for washing the bodies of the dead (especially for foreigners who died far from home, given Tangier's role as a port). On the mosque's northwestern side, across the street from its main entrance, was a madrasa (school) built in the 18th century under sultan Muhammad ibn 'Abdallah. Attached directly to the mosque itself, behind its southeastern wall (the qibla wall), was a library and a funeral mosque (jama' al-gna'iz, where funerary rites where performed before the body's burial). Some of these amenities were managed and funded by the habous (or waqf) of the mosque; that is, a charitable trust under which the mosque drew revenues from various sources for its upkeep and the upkeep of its associated establishments.
In the decades prior to colonial rule and the establishment of an international (European) regime governing Tangier (between 1924 and 1956), the mosque's civic importance declined and the fiscal assets of its habous were increasingly confiscated or diverted by the government. Under colonial rule all habous establishments were further curtailed and lost their role as agents of urban development. Like in many other North African cities, a Ville Nouvelle ("New City") was established outside the old city walls and rapidly outgrew it, thus reducing th
Grand Mosque of Tangier