The Battle of the Ailaish River (1499) was a defeat suffered by Babur's supporters soon after he had regained control of his original kingdom of Fergana after a year spent in exile.
Babur had lost control of Fergana in the aftermath of his first successful attack on Samarkand, the city that was his main objective for most of his life. Soon after Babur captured that city two of his nobles, Auzun Hasan and Sultan Ahmad Tambal, had rebelling in the name of Babur's brother Jahangir. They captured Andijan, the capital city, on the same day that Babur left Samarkand in an attempt to lift the siege. Babur was briefly left without a kingdom.
In the spring of 1499 Babur made a sudden come-back. Ali-dost Taghai, the man who had surrendered Andijan to Babur's enemies in the belief that he was seriously ill, now offered to give him control of the walled town of Marghinan. Babur took up the offer, and then fought off an attempt by Auzun Hasan and Sultan Ahmad Tambal to besiege him there. The usurper's failure cost them control of the kingdom. The commander of Andijan declared for Babur, and in June 1499 he re-entered his capital. Sultan Ahmad Tambal and Jahangir fled east to Auzkint, while Auzun Hasan went west to Akhsi, where he was soon forced to surrender.
Babur's success was short-lived. Many of the troops on both sides in the civil wars were Mongol (or Mughal) mercenaries. Many of Auzun Hasan's Mongols had abandoned him at Akhsi, expecting to swap to Babur's service without any penalty. The problem was that many of Babur's long-standing supporters had suffered at their hands. Babur ordered the Mongols to return any property that they had taken from his supports. Rather than do this the Mongols left his service, and marched towards Auzkint, where they offered their services to Tambal. Many of Babur's own Mongol mercenaries joined them.
Babur's advisors badly underestimated the threat posed by the combined forces of Tambal and the Mongols, and convinced him not to take the field against them in person. Instead Qasim Beg, with an army made up only of the troops currently in Andijan, was sent out to deal with the threat.
On the day after leaving Andijan Qasim Beg's army crossed a river that Babur called the Ailaish (probably the Qara-darya, a tributary of the Sirr River). Tambal had clearly not wasted any time in joining the Mongols, for the moment Babur's men crossed the river they came face-to-face with the rebels.
Babur's account of the battle gives no information on the overall events of the battle, but instead focuses on a list of which of his men were captured and which escaped, and on a duel between two of the fighters. Qasim Beg and Ali-dost Taghai were amongst those who escaped, along with three other named leaders and three or four unnamed begs and members of Babur's household, but most of the other leaders were captured.
In the aftermath of this victory Tambal besieged Andijan, but failed to make any progress, and after a month departed towards Aush (modern Osh, thirty miles to the south-east of Andijan). Babur besieged Tambal's younger brother in Madu, before the two armies finally met in battle at Khuban (between Osh and Andijan). Although Babur won this battle, his chief supports then insisted that the kingdom be divided between him and Jahangir.