Battle of Algami Canal

The Battle of Algami Canal was fought between Kara Koyunlu under their Bey, Qara Yusuf and the Timurid Empire under the leadership of Timur's grandson Abu Bakr bin Miran Shah for control of Baghdad and therefore Iraq in late 1402.

Background
When the Ilkhanate collapsed into rival Mongol tribes namely the Chopanids, Jalayirids, Muzaffarids and Injuids, their internal conflicts coupled with external invasions had rendered them weak and ideal targets for an invasion by Timur the Lame in 1393. He overran Iran, Iraq, Azerbaijan, Armenia, Georgia, and sacked portions of eastern Anatolia then returned to Samarkand by 1396. In this campaign he extinguished the Muzaffarids of Iran. But he could not manage to erase the Jalayirids under Sultan Ahmed Jalayir and their subordinate Turkmen clan of Kara Koyunlu under Qara Muhammad Turemish and his son Qara Yusuf.

Eventually he embarked on a campaign against the fugitives Sultan Ahmed Jalayir and Qara Yusuf. But the Ottoman Empire gave them refuge. Meanwhile, The Mamluk Sultanate of Egypt under Nasir-ad-Din Faraj too became his enemy for the unlawful detention of Timur's envoy. Timur the Lame now directed his campaign against these two powers before concentrating on Sultan Ahmed Jalayir and Qara Yusuf. He first took Syria from the Mamluks and then turned his attention back to Iraq. He besieged Baghdad on June 20, 1401 and took the city by storm. He then turned towards Georgia and on July 20, 1402 he defeated Sultan Bayezid I of the Ottoman Empire at the Battle of Ankara.

During this battle of the titans, Sultan Ahmed Jalayir and Qara Yusuf had left for Iraq again. But a rupture between the two forced Sultan Ahmed Jalayir to escape towards Tikrit while Qara Yusuf took over Baghdad.

Battle
Timur was quick to dispatch his grandson Abu Bakr bin Miran Shah to restore Timurid authority in Iraq. He marched with an army and reached the banks of Algami Canal between Baghdad and Hillah where he met the forces of Qara Yusuf who put up a brave fight but was utterly defeated in late 1402.

Aftermath
Sultan Ahmed Jalayir and Qara Yusuf both escaped Iraq again and fled towards Egypt this time. However, for political reasons they were imprisoned by Sultan Nasir-ad-Din Faraj who wrote a letter to Timur informing him of the fact. Timur asked for the prisoners but Faraj had a change of heart and refused. Together in prison, the two leaders renewed their friendship, making an agreement that Ahmed should keep Baghdad while Qara Yusuf would have Azerbaijan if ever they get out alive. When Timur died in 1405 the Mamluk Sultan Nasir-ad-Din Faraj released them both in return for accepting him as their overlord. But the two went their separate ways and made nothing of the Mamluk deal of suzerainty. Sultan Ahmed Jalayir went to Hillah and organized a rebellion against the Timurid governor of Baghdad and took the city. Meanwhile, Qara Yusuf went to Azerbaijan in an attempt to take it.