The departure, celebrated as a victory by Tehran and its allies, was agreed in 2024 under President Biden and carried out by the Trump administration.