After the devastating invasions by Timur and subsequent enfeeblement of the Kingdom of Georgia, it soon faced a new threat. Timur's death in 1405 marked the beginning of the end of his Empire, unified only by fear and blood of the subjected peoples. Turkomans, particularly the Kara Koyunlu clan, were among the first to rebel against Shah Rukh who ruled most of the Persia and Mawerannahr. Qara Yusuf, ruler of the Kara Koyunlu, defeated Shah Rukh, captured Baghdad, and repulsed Timurids from western Persia. After they established themselves as the new leading power in the middle east. They took advantage of the temporary weakness of Georgians and launched attacks against them, apparently in which, George VII of Georgia was killed. Constantine I of Georgia, fearing further encroachment, allied himself with the Shirvanshah Ibrahim I to counter Turkoman advance and engaged them in the Battle of Chalagan, in which he was defeated and taken captive. In captivity Constantine behaved very proudly, which infuriated Qara Yusuf to such an extent, that he ordered his, his half-brother David's and 300 Georgian nobles' execution. Alexander I of Georgia who sought to strengthen and restore his declining Kingdom, faced constant invasions by the tribal Turkomans. They sacked Akhaltsikhe, city of the vital regional importance in 1416, in response of suggested oppression of Muslims. Alexander re-conquered Lorri from the Turkomans in 1431, which was of great importance in securing of the Georgian borders. Around 1434/5, Alexander encouraged the Armenian prince Beshken II Orbelian to attack the Kara Koyunlu clansmen in Siunia and, for his victory, granted him Lorri under terms of vassalage. In 1440, Alexander refused to pay tribute to Jahan Shah of the Kara Koyunlu. In March, Jahan Shah surged into Georgia with 20,000 troops, destroyed the city of Samshvilde and sacked the capital cityTbilisi. He massacred thousands of Christians, put heavy indemnity on Georgia, and returned to Tabriz. He also mounted a second military expedition against Georgia in 1444. His forces met those of Alexander’s successor, King Vakhtang IV at Akhaltsikhe, but the fighting was inconclusive and Jahan Shah returned to Tabriz once more. As a result of foreign and internal struggles unified Kingdom of Georgia stopped to exist after 1466 and was subdivided into several political units. Kara Koyunlu tribal confederation was destroyed by Aq Qoyunlu, their kin tribesmen who formed another confederation, which was similar in many ways to its predecessor. Aq Qoyunlu Turkomans naturally took advantage of the Georgian fragmentation. Georgia was at least twice attacked by Uzun Hasan, the prince of the Aq Qoyunlu in 1466, 1472 and possibly 1476-7. Bagrat VI of Georgia, temporary ruler of most of Georgia at the time, had to make peace with the invaders, abandoning Tbilisi to the enemy. It was only after Uzun Hasan’s death when the Georgians were able to recover their capital. In the winter of 1488, the Ak Koyunlu Turkomans led by Halil Bey attacked Georgia’s capital Tbilisi, and took the city after a long-lasted siege in February 1489. Alexander II of Imereti, another pretender to the throne, took advantage of the Aq Qoyunlu Turkoman invasion of Kartli, and seized control of Imereti. Occupation of the capital did not last long and Constantine II of Georgia was able to repel them, but it was still costly to Georgians. Ismail I, founder of the Safavid dynasty, formed an alliance with the Georgians in 1502 and decisively defeated Aq Qoyunlu in the same year, destroying their state and marking the end of their invasions.