The Khanate of Kokand was established in 1709 when the Shaybanid emir Shahrukh, of the Ming Tribe of Uzbeks, declared independence from the Khanate of Bukhara, establishing a state in the eastern part of the Fergana Valley. He built a citadel as his capital in the small town of Kokand, thus starting the Khanate of Kokand. His son, Abdul Kahrim Bey, and grandson, Narbuta Bey, enlarged the citadel, but both were forced to submit as a protectorate, and pay tribute to, the Qing dynasty in China between 1774 and 1798. Narbuta Bey’s son Alim was both ruthless and efficient. He hired a mercenary army of Tajik highlanders, and conquered the western half of the Fergana Valley, including Khujand and Tashkent. He was assassinated by his brother Umar in 1811. Umar’s son, Mohammed Ali, ascended to the throne in 1822 at the age of 12. During his reign, the Khanate of Kokand reached its greatest territorial extent. The Kokand Khanate also housed the Khojas of Kashgar like Jahangir Khoja. In 1841, the British officer Captain Arthur Conolly failed to persuade the various khanates to put aside their differences, in an attempt to counter the growing penetration of the Russian Empire into the area. In November 1841, Captain Conolly left Kokand for Bukhara in an ill-fated attempt to rescue fellow officer Colonel Charles Stoddart, and both were executed on 24 June 1842 by the order of Emir Nasrullah Khan of Bukhara. Following this, Madali Khan, who had received Conolly in Kokand, and who had also sought an alliance with Russia, lost the trust of Nasrullah. The Emir, encouraged by the conspiratorial efforts of several influential figures in Kokand, invaded the Khanate in 1842. Shortly thereafter he executed Madali Khan, his brother, and Omar Khan's widow, the famed poet Nodira. Madali Khan’s cousin, Shir Ali, was installed as the Khan of Kokand in June 1842. Over the next two decades, the khanate was weakened by a bitter civil war, which was further exacerbated by Bukharan and Russian incursions. Shir Ali’s son, Khudayar Khan, ruled from 1844 to 1858, from 1862 to 1863, and from 1865 to 1875. In the meantime, Russia was continuing its advance; on 29 June 1865 Tashkent was taken by the Russian troops of General Chernyayev; the loss of Khujand followed in 1867. Shortly before the fall of Tashkent, Kokand’s best-known son, Yakub Beg, former lord of Tashkent, was sent by the then Khan of Kokand, Alimqul, to Kashgar, where the Hui Muslims were in revolt against the Chinese. When Alimqul was killed in 1865 during the battle with Russia for Tashkent, many Kokandian soldiers fled to join Yaqub Beg, helping him establish his dominion throughout the Tarim Basin, which lasted until 1877, when Qing reconquered the region. In 1868, a treaty turned Kokand into a Russian vassal state. The now powerless Khudayar Khan spent his energies improving his lavish palace. Western visitors were impressed by the city of 80,000 people, which contained some 600 mosques and 15 madrasahs. Insurrections against Russian rule and Khudayar’s oppressive taxes forced him into exile in 1875. He was succeeded by his son, Nasruddin Khan, whose anti-Russian stance provoked the annexation of Kokand by Generals Konstantin von Kaufman and Mikhail Skobelev. In January 1876, Tsar Alexander II stated that he had been forced to "... yield to the wishes of the Kokandi people to become Russian subjects." The Khanate of Kokand was declared abolished, and incorporated into the Fergana Oblast of Russian Turkestan.