Ahmad al-Mansur al-Dhahabi — "the Golden" — had good reason for the nickname. In 1578 Morocco routed a Portuguese invasion at the Battle of the Three Kings and took a king’s ransom in prisoners. Al-Mansur spent a significant portion of that windfall, plus ongoing Saharan gold trade revenue, on a palace complex intended to announce Saadian Morocco as a world power.
Construction ran from roughly 1578 to 1602. Contemporary accounts describe 360 rooms, an audience hall whose ceiling was supported by Italian marble columns, a courtyard pool measuring 90 by 20 metres, gilded plasterwork and cedarwood from the Middle Atlas. An ambassador from Elizabethan England visited and reportedly called it the finest palace in the world. Whether or not that was diplomatic flattery, the effect on visitors was clearly intended to overwhelm.
Al-Mansur died in 1603 during a plague, and the Saadian dynasty crumbled into civil war. When the Alaouite sultan Moulay Ismail consolidated power and chose Meknes as his capital, he saw El Badi as a convenient quarry. Between roughly 1684 and 1696 he dismantled the palace systematically, sending columns, tiles, marble pavements and gilded panels north. A contemporary account says the operation took twelve years of continuous labour. The earthen shell — the parts no one could profitably carry — was left standing, and has been slowly mellowing into the Marrakech skyline ever since.