Soon they were both imprisoned on the order of Nasir-ad-Din Faraj. Together in prison, the two leaders renewed their friendship, making an agreement that Sultan Ahmed Jalayir should keep Baghdad while Qara Yusuf would have Azerbaijan. Ahmad also adopted his son Pirbudag.