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.