Ali-Tegin

Ali ibn Hasan, also known as Harun Bughra Khan and better known as Ali-Tegin (also spelled Alitigin) was a Karakhanid ruler in Transoxiana from 1020 to 1034 with a brief interruption in 1024/25.

Origins
He was the son of Hasan ibn Sulayman Bughra Khan (simply called "Bughra Khan" in Persian sources), who was the eponymous ancestor of the eastern branch of the Karakhanid family, known as the "Hasanids", to which Ali-Tegin belonged. Hasan is only known from Persian sources because of his wars with the Iranian Samanids, who used to be the rulers of Transoxiana before the Karakhanids under Nasr Khan annexed their territories in 999.

Rise to power
Ali-Tegin is first mentioned as being thrown in prison under the orders of his opponent Mansur Arslan Khan, but quickly managed to escape and receive help from a group of Oghuz Turks led by the Seljuq chief Arslan Isra'il. With these Oghuz Turks in his grasp, Ali-Tegin seized Bukhara and soon occupied all of Sogdia; after his conquest of the region, he took the titles of "Yïgan-tigin" and "Arslan Ilig". He gave his daughter in marriage to Arslan Isra'il. With the possession of the wealthy and important cities of Bukhara and Samarkand, Ali-Tegin became a powerful and influential figure in Central Asia; however, this strained his relations with his jealous brother Yusuf Qadir Khan, which resulted in the latter allying himself with the Ghaznavid Sultan Mahmud ((r. 998 – 1030)), who had received expressions of discontent from Ali-Tegin's subjects and was himself annoyed by Ali-Tegin, who did not allow him to send envoys to Qadir Khan, who controlled two important cities, Khotan and Kashgar. Ali-Tegin, after learning of his brother's alliance with the Ghaznavids, responded by allying himself with his other brother Muhammad Toghan Khan.

Conflict with the Ghaznavids
In 1024/5, a combined army under Mahmud and Qadir Khan invaded Ali-Tegin's territories and completely defeated him and his Seljuq supporters. Ali-Tegin then fled to the steppes, whilst Mahmud and Qadir Khan made a marriage alliance at Samarkand. One of Mahmud's officers captured Ali-Tegin's family as they fled towards the steppes. Meanwhile, Arslan Isra'il fled to Ghaznavid territory in Khorasan and asked for permission to settle in the region in return for protecting the Ghaznavid borders from incursions by the other Turks of Transoxiana. Mahmud, not trusting him and his followers, had them imprisoned.

Fortunately for Ali-Tegin, Mahmud had to withdraw from Transoxiana in order to prepare another expedition in India, giving Ali-Tegin an opportunity to counter-attack Qadir Khan and re-conquer his former territories. Ali-Tegin, although no longer enjoying the support of Arslan Isra'il, still had assistance from the latter's nephews Tughril and Chaghri Beg. Ali-Tegin quarreled with the Seljuqs in 1029, but they still continued to serve and support him.

After a brief civil war in the Ghaznavid state in 1030, Mahmud's son Mas'ud I became the new ruler of the Ghaznavid Empire, and continued his father's aggressive policy towards Ali-Tegin; Mas'ud now intended to once and for all conquer Transoxiana from Ali-Tegin and to give it to Qadir Khan's second son, who was his own brother-in-law, Muhammad Bughra Khan. In 1032, the Ghaznavid governor of Khwarazm, Altun Tash, captured Bukhara, and an inconclusive battle was shortly fought at Dabusiyya; Altun Tash died during the battle, but one of his most trusted officers, Ahmad Shirazi, successfully negotiated a treaty with Ali-Tegin, who agreed to return to Samarkand, whilst the Ghaznavid army withdrew back to their own territories.

Meanwhile, in Khwarazm, Altun-Tash's son Harun became the new ruler of the region. However, unlike his father, he was hostile to the Ghaznavids and in 1034 made an alliance with Ali-Tegin, with whom he planned to invade Khorasan. However, before the invasion could take place, Harun was assassinated by his own slaves, at the instigation of Mas'ud. Ali-Tegin died in the same year; his sons continued to preserve their father's authority in Transoxiana for a few years, until their relative Böritigin ((r. 1038 – 1068)) of the Alid branch seized their territories.