On July 27, 1980, the former Shah died; then, in September, Iraq invaded Iran. These two events led the Iranian government to enter negotiations with the U.S., with Algeria acting as a mediator. The hostages were formally released into United States custody the day after the signing of the Algiers Accords, just minutes after the new American president, Ronald Reagan, was sworn into office.