This is the list of rulers of Morocco, since the establishment of the first Moroccan state in 789. The common and formal titles of these rulers has varied, depending on the time period. Since 1957, the title King has been used.

Idrisid dynasty
Idriss I (789–791)
Idriss II (791–828)
Muhammad ibn Idris (828–836)
Ali ibn Idris (836–848)
Yahya ibn Muhammad (848–864)
Yahya ibn Yahya (864–874)
Ali ibn Umar (874–883)
Yahya ibn Al-Qassim (883–904)
Yahya ibn Idris ibn Umar (904–917)

The first period of Fatimid overlordship lasted from 922 to 925.

Hassan I al-Hajam (925–927)

The second period of Fatimid overlordship lasted from 927 to 937.

Al Qasim Gannum (937–948)
Abu l-Aish Ahmad (948–954)
Al-Hasan ben Kannun (954–974)

In 974, the Sultan Al-Hasan ben Kannun was defeated by Cordobese Umayyads. A period of Umayyad overlordship followed then.

Almoravid dynasty
 Abu Bakr ibn Umar (c. 1060–1072)
Yusuf ibn Tashfin (1072–1106)
Ali ibn Yusuf (1106–1142)
Tashfin ibn Ali (1142–1146)
Almohad uprising started in 1145
Ibrahim ibn Tashfin (1146)
Ishaq ibn Ali (1146–1147)

Almohad dynasty
'Abdul-Mu'min (1145–1163)
Abu Yaqub Yusuf I (1163–1184)
Aby Yusuf Yaqub al-Mansur (1184–1199)
Muhammad an-Nasir (1199–1213)
Abu Yaqub Yusuf II (1213–1224)
Abdul-Wahid I (1224)
Abdallah al-Adil (1224–1227)
Yahya (1227–1235)
Idris I (1227–1232)
Abdul-Wahid II (1232–1242)
Ali (1242–1248)
Marinid overlordship, from 1248 until the fall of the Almohads in 1269
Umar (1248–1266) - based in Marrakech, with local power only
Idris II (1266–1269) - in Marrakech, with local power only

Marinid dynasty
Abu Yahya ibn Abd al-Haqq (1244–1258)
Umar (1258–1259)
Abu Yusuf Yaqub ibn Abd Al-Haqq (1259–1286)
Abu Yaqub Yusuf an-Nasr (1286–1306)
Abu Thabit Amir (1307–1308)
Abu al-Rabi Sulayman (1308–1310)
Abu Sa'id Uthman II (1310–1331)
Abu al-Hasan Ali ibn Othman (1331–1348)
Abu Inan Faris (1348–1358)
Muhammad II. as Said (1359)
Abu Salim Ali II. (1359–1361)
Abu Umar Taschufin (1361)
Abu Zayyan Muhammad III. (1362–1366)
Abu l-Fariz Abdul Aziz I. (1366–1372)
Abu l-Abbas Ahmad (1372–1384)
Musa ibn Faris (1384–1386)
Al-Wathiq (1386–1387)
Abu l-Abbas Ahmad (1387–1393)
Abu Faris Abdul Aziz II. (1393–1396)
Abdullah (1396–1399)
Abu Said Uthman III. (1399–1420)
Abdalhaqq II (1420–1465)

Idrisid interlude
Muhammad ibn Ali Idrisi-Joutey (1465–1471)

Wattasid dynasty
Abu Zakariya Muhammad al-Saih al-Mahdi (1472–1505)
Abu Abdallah Muhammad I (1505–1524)
Abul Abbas Ahmad (1524–1545)
Nasir ad-Din al-Qasri (1545–1547)
Abul Abbas Ahmad (second time, 1547–1549)
Ali Abu Hassun (Jan.–Sep. 1554)

Saadi dynasty
Mohammed ash-Sheikh (1549–1554, 1554–1557)
Abdallah al-Ghalib	(1557–1574)
Abu Abdallah Mohammed II (1574–1576)
Abu Marwan Abd al-Malik I (1576–1578)
Ahmad al-Mansur (1578–1603)

1603–1627: Succession war

Main Saadian rulers, based in Marrakesh:
Abou Fares Abdallah (r. 1603–1608)
Zidan el Nasir (pretender since 1603, r. 1608–1628)

Splinter faction based in Fes, with only local power:
Mohammed esh Sheikh el Mamun (r. 1603–1613)
Abdallah II (r. 1613–1623)
Abd al-Malik ibn Abdallah (r. 1623–1627)

1627–1659: Reunified rule
Abu Marwan Abd al-Malik II (r. 1627–1631)
Al Walid ibn Zidan (r. 1631–1636)
Mohammed esh Sheikh es Seghir (r. 1636–1655)
Ahmad el Abbas (r. 1655–1659)

Dila'i interlude
Muhammad al-Hajj ad-Dila'i (r. 1659–1663)

Alaouite dynasty
1666–1957: Alaouite sultans of Morocco

1957–Present: Alaouite kings of Morocco

Other websites
The Alawi Dynasty Royal Ark

Moroccan