In the year A.H. 541 (1147) Sanjar again attacked Atsiz, but a permanent reconciliation was soon attained.[321]
In A.H. 551 (1156)[322] Atsiz died at the age of sixty-one, and was succeeded by his son Il-Arslān, with whom the independent dynasty of Khwārazm-Shāhs properly begins. Meanwhile the affairs of Sultan Sanjar were going from bad to worse, and the end of the last great Seljūk was as ignoble as his career had been glorious. Strange to say, his ultimate ruin was caused by a Turkish tribe who came of the same stock as the Seljūks themselves.
The domination of the Kara-Khitāys in Transoxiana does not appear to have affected the condition of the dwellers in towns, the peaceful Tājiks, who were even allowed to appoint their own tax-collectors and other officials.[323] The only classes who suffered at the hands of the invaders were the Ghuz Turks, who were nomads like the Kara-Khitāys themselves, and occupied all the best pasture-grounds. They now found themselves forced to seek fresh fields. Crossing the Oxus, they obtained permission from Sanjar to settle in Khatlān, Chaghāniyān, and the environs of Balkh.[324] They numbered, we are told, 40,000 families, and the tribute imposed upon them was an annual contribution to the royal kitchen of 24,000 sheep. These supplies were carried off as occasion required by an officer of the Household.[325] On one occasion the man sent to fetch the sheep was so scrupulous in his choice that the Ghuz took offence and put him to death. The chief butler was thus obliged to supply the royal kitchen from his own flocks. The official complained of this outrage to Kamāj, the governor of Balkh, who immediately reported it to Sultan Sanjar, offering to bring the Ghuz to obedience, and further to extract from them 30,000 sheep for the royal kitchen. With the Sultan’s permission he returned to Balkh and demanded of the Ghuz the sheep that had been withheld; but the herdsmen refused to comply, adding that the Sultan of Merv was their master, not the governor of Balkh. Kamāj, much incensed at the slight put upon his authority, attacked the nomads, but in the first engagement he was utterly put to rout.[326] On hearing of this disaster, Sultan Sanjar marched on Balkh at the head of 100,000 men.[327] In spite of his vast numerical superiority he suffered a crushing defeat, A.H. 548 (1153), and was taken prisoner.[328] Intoxicated by this unlooked-for success, the Ghuz attacked the capital itself. They found the Merv oasis in a state of brilliant prosperity;[329] for since the days of Chakir Beg it had never been molested, and, as the author of the _Rawzat-us-Safā_ says,[330] “it had slumbered in peace and tranquillity.” The greedy nomads, spurred to madness by the sight of so much wealth, seized all that met their eyes, and then tortured the inhabitants till they revealed their hidden treasures.[331] The fallen Sultan, meanwhile, was kept in close confinement,[332] but was treated with the respect due to his rank. Having ransacked Merv, the Ghuz laid waste the whole of Khorāsān, so that, says Mīrkhwānd, “not a single spot in that province escaped their destructive hands.” Sanjar remained for about four years in captivity; and while his consort, Turkān Khātūn, who acted as queen-regent, lived, he made no attempt to escape, lest harm should befall her. On her death, in A.H. 551 (1156), he took advantage of a hunting expedition to evade his captors. Gathering a few devoted followers on the other side of the Oxus, he set out for his capital, but on reaching Merv he was so heartbroken at the desolation that met his eyes that he sickened and died.[333] The ruins of his splendid mausoleum are the chief glory of ancient Merv. It was built by him during his lifetime; and so great was its solidity that he gave it the name of _Dār ul-Ākhirat_, “the Abode of Eternity.” Sixty years after his death it was destroyed by Chingiz Khān.