With the help of new Arab immigrants he gained independence from his Berber allies and extended Idrisid control to include most of what is today Morocco and parts of eastern Algeria.
He and his successors turned Fez into an important capital and urban center of Morocco, and the city accrued prestige with the creation of institutions like the Qarawiyyin Mosque and University in 859.
[5] While there is disagreement among sources as to what happened to Idris II's body after his death, most believe that he was buried in the mosque he had built next to his palace of Dar al-Qaytun (House of the Tent) in the center of Fes, possibly in a mausoleum on its eastern side.
[7]: 33, 49 [8] The 11th-century author Al-Bakri described the mosque as consisting of a hypostyle prayer hall with three transverse aisles oriented roughly east-to-west and a large courtyard (sahn) planted with olive trees.
[2] Moussa ibn Abi al-'Afya, whom the Zenata placed in charge of Fez, persecuted the descendants of Idris, drove them out of the city, and took measures to discredit their reputation.
[9] In 1069 Fez was conquered by the Almoravids, who promoted a stricter and more orthodox version of Sunni Islam (following the Maliki maddhab) which was hostile to the cult of "saints",[2] resulting in another exodus of the sharifian families from the city.
[5] As the Idrisids lost power and Fez came under the control of other rulers who were hostile to their influence, the mosque and the mausoleum were neglected and eventually abandoned, and the cult of Moulay Idris II along with it.
Unlike these previous dynasties, however, their political legitimacy was not based on a program of religious reform or on a strong role in defending the Muslim frontier in al-Andalus (Spain) at the time.
Among other means, they did this by constructing many new madrasas promoting the Maliki Sunni maddhab and its scholars (who became their bureaucracy), while at the same time cautiously fostering the various sharifian dynasties and factions inside Morocco for support.
Notably, when the body of Idris I was allegedly rediscovered in Walili (Volubilis) in 1318, which generated excitement among locals, Marinid officials quickly moved to prevent the story from spreading.
The cult surrounding Moulay Idris II slowly rekindled, and by the 16th century it was strong and even actively encouraged by the Wattasid rulers (the successors to the Marinids), with regular ceremonies taking place around the tomb.
[1] At a more national level, the renewed prestige of the sharifs in general was so successful that two sharifian dynasties, the Saadis and the 'Alawis (the current monarchy to this day), subsequently took over and ruled Morocco.
[5] In 1603, the last year of Sultan Ahmad al-Mansour's reign, his son, Emir (prince) Zaydan Abu Maali, added more decoration inside the mausoleum.
[5] Most significantly of all, Moulay Ismail, the powerful and long-reigning Alaouite sultan, had the entire zawiya rebuilt between 1717 and 1720, including the current minaret and the mausoleum chamber with its large pyramidal roof.
[7] Further west, on the south side of Place Nejjarine, is the historic Hammam Moulay Idris which is associated with his tomb and traditionally considered to confer some of its blessings.
Up until the beginning of the French colonial occupation in 1912, non-Muslims and pack animals (e.g. mules, commonly used in the old city) were forbidden to pass beyond this point, and any Muslim within this space was allowed to claim asylum from arrest or prosecution.
The most monumental entrance portal of the zawiya building is on its north side, at the foot of the minaret and at the end of a lane leading directly off the major souq street of Tala'a Kebira.
[20]) The east side of the complex, adjacent to the courtyard and the mausoleum, is a roofed hypostyle space for prayer, including the mosque space built by Sultan Abd al-Rahman in 1824.A number of ornate marble columns, capitals, and panels throughout the complex, as well as an ornate marble arch for the window of the muwaqqit's or timekeeper's chamber (Dar al-Muwaqqit) overlooking the courtyard, all appear to be Saadi in origin, probably stripped by Moulay Ismail from Saadi palaces like the famous el-Badi in Marrakech and re-used in new prestigious buildings elsewhere.
Notably, the external south wall of the building features a grilled window which connects directly to the tomb and where passing Muslims can offer short prayers to bless Moulay Idriss II.
[4] The zawiya has for centuries played a role in the yearly celebration of Mouloud (the anniversary of the Prophet Muhammad's birth), notably as the starting point for the procession of the city's artisans' guilds, which still takes place today.