 In 1017, a young Muhammad was declared shah by the murderers of his uncle Abu'l Abbas Ma'mun.Mahmud of Ghazna, who had been Ma'mun's brother-in-law, was afforded a pretext for invading and a force was assembled in northern Khurasan.The Khwarazamis were unable to provide any effective resistance, and Muhammad was captured and imprisoned; Khwarazm therefore became a part of the Ghaznavid Empire.