A civil war between two brothers Umar Shaikh Mirza II (father of Babur), King of Fergana and Sultan Ahmed Mirza, King of Samarkand and Bukhara was being fought in 1492 when Umar Shaikh died of natural causes leaving his son, the 12-year old Babur in charge of his Kingdom. Ahmed Mirza, Babur's uncle wasted no time in attacking Babur's Kingdom but failed in his attempt. Ahmed Mirza later also died of natural causes. After Sultan Ahmed Mirza’s death, Sultan Mahmud Mirza moved to Samarkand and reigned there for some five or six months, reportedly attempting to regulate the collection of taxes and strengthen his army. But with the deaths of Sultan Ahmed Mirza, Sultan Mahmud Mirza and Umar Shaikh Mirza II, all occurring during the space of a year, civil strife intensified. The richest amirs tried to make use of the child Timurids, preferring to enthrone the weakest of them.Sultan Ali Mirza bin Mahmud Mirza was thus raised in Bukhara. But the young Timurid Sultan Baysonqor Mirza bin Mahmud Mirza’s coming to power in Samarkand roused the governors of other provinces. Sultan Ali Mirza left Bukhara on a campaign against Samarkand, but the inhabitants of the city put up a fierce resistance. These events and the confusion and anarchy with which they were attended in the kingdom of Samarkand did not escape the observation of Babur who resolved to try his fortune. In 1496, the 15-year old Babur marched to attack Samarkand. At the same moment and induced by the same motives Sultan Masud Mirza the older brother of Sultan Ali Mirza and Baysonqor Mirza was on his way to besiege the city. Thus that unfortunate city, unfortunate from its very wealth and former prosperity, saw itself beleaguered on three sides at the same time by the arms of three different potentates who acted without concert; Babur having advanced towards it from Andijan; Masud Mirza from Hissar and Sultan Ali from Bukhara.
Sultan Ali now proposed to Babur that they should enter into a treaty of alliance and mutual co operation to which Babur willingly agreed. attended by a limited number of followers But as the autumn was already drawing to a close and winter fast approaching and as the country round Samarkand exhausted by the presence of so many armies was altogether unable to furnish the requisite provisions and provender for the troops all the invading princes were to withdraw into their own territories. However, Babur and Sultan Ali decided that as soon as the winter season was over they would return and besiege the city again.