The Timurids began another campaign in 1400 and defeated both the Qara Qoyunlu and the Jalayirids. Qara Yusuf and Sultan Ahmed Jalayir both fled and took refuge with the Mamelukes first, then Ottoman Sultan Bayezid I. In 1402 they returned together with an army. However, once they had retaken control of Baghdad they quarreled, and Qara Yusuf expelled Sultan Ahmed Jalayir from the city.