 Shortly after Ghiyath's death, however, the Khwarazmian-shah Muhammad II invaded the Ghurid Empire, and besieged Herat.Mu'izz, along with his general Husain ibn Kharmil, quickly managed to Muhammad from Herat and then pursued him to Khwarezm, where the Ghurid army besieged the Khwarazmian capital of Gurganj.However, the Ghurids were shortly forced to retreat back to Ghur, but suffered a heavy defeat during the defeat.