This was known as Iran-Contra affair.
It was a scandal in the administration of President Ronald Reagan which came to light when it was revealed that in the mid-1980s he US secretly arranged the arms sales to Iran in return for promises of Iranian assistance is securing the release of Americans held hostage in Lebanon. Proceeds from the arms sales then were covertly and illegally funneled to the Contras, rebels fighting the Marxist Sandinasta government in Nicaragua.