orientation, as can be seen in major early mosques like the Great Mosque of Cordoba and the Qarawiyyin Mosque in Fes. This was based on a reported hadith of the Islamic prophet Muhammad which stated that "what is between the east and west is a qibla", as well as on a popular view that mosques should not be aligned towards the Kaaba but rather that they should follow the cardinal orientation of the Kaaba itself (which is a rectangular structure with its own geometric axes), which is in turn aligned according to certain astronomical references (e.g. its minor axis is aligned with the sunrise of the summer solstice). Synagogues Although much reduced today, the Jewish community of Morocco has a long history, resulting in the presence of many synagogues across the country (some of which are defunct and some of which are still functioning). Synagogues had a very different layout from mosques but often shared similar decorative trends as the rest of Moroccan architecture, such as colourful tilework and carved stucco, though later synagogues were built in other styles too. Notable examples of synagogues in Morocco include the Ibn Danan Synagogue in Fes, the Slat al-Azama Synagogue in Marrakesh, or the Beth-El Synagogue in Casablanca, though numerous other examples exist. Madrasas The madrasa was an institution which originated in northeastern Iran by the early 11th century and was progressively adopted further west. These establishments provided higher education and served to train Islamic scholars, particularly in Islamic law and jurisprudence (fiqh). The madrasa in the Sunni world was generally antithetical to more "heterodox" religious doctrines, including the doctrine espoused by the Almohad dynasty. As such, it only came to flourish in Morocco in the late 13th century, under the Marinid dynasty which succeeded the Almohads. To the Marinids, madrasas also played a part in bolstering the political legitimacy of their dynasty. They used this patronage to encourage the loyalty of the country's influential but independent religious elites and also to portray themselves to the general population as protectors and promoters of orthodox Sunni Islam. Finally, madrasas also played an important role in training the scholars and elites who operated the state bureaucracy. Madrasas also played a supporting role to major learning institutions like the Qarawiyyin Mosque; in part because, unlike the mosque, they provided accommodations for students who came from outside the city. Many of these students were poor, seeking sufficient