Sultan Shah was the younger son, but he was considered the formal heir and his mother, Terken Khatun, placed him on the throne.
The elder son, Ala ad-Din Tekish, fled to the Qara Khitai and asked for them to enthrone him in place of his brother, promising an annual tribute in exchange.
Following Ai-Aba's death, Sultan Shah eventually found refuge with the Ghurids, but Terken Khatun was hunted down and killed by Tekish's forces.
The bulk of the Qara Khitai army decided to return home, but Sultan Shah convinced its commander to leave a contingent of troops with him.
In 1192 Sultan Shah decided to launch an expedition against Khwarazm, taking advantage of Tekish's absence there; the latter was at the time in western Iran dealing with the Seljuks of Hamadan.