Malwa gained independence from the Dihli sultanate at the time that Timur invaded India and captured Dihli in 801 H/1398 CE. The reigning Tughluqid Sultan, Mahmud ibn Muhammad, fled to Malwa and was given asylum by the governor of the town, Dilaver Khan Husayn Ghuri, until he felt safe enough to return. The damage done to the Dihli Sultanate by Timur’s invasion gave Dilaver Khan the chance to declare his independence, but he did not assume a royal title or strike coins in his name. He established his capital in the heavily fortified city of Mandu, which became known as Shadiabad, and was renowned for the magnificent buildings that were constructed within its walls. In 808 H/1405 CE Dilaver Khan’s son, Hushang Shah, had his father poisoned, replaced him on the throne and asserted full independence. The reigns of Hushang and his successors were spent in campaigning against neighbouring states and internal dissent. However, in 839 H/1436 CE the last of the Ghuri sultans, Mas‘ud Khan, fled to Gujarat, and his chief minister, Mahmud Khalji, seized power for himself and became Malwa’s greatest ruler. Mahmud’s son Ghiyath Shah, who was made heir apparent in 861 H/1457 CE, issued coinage in his own name as wali ‘ahd and then as Sultan after Mahmud’s death in 873/1469. He inherited a prosperous and stable state, and did not mount any military campaigns, preferring to consolidate his father’s achievements rather than make new conquests.