The agreement will end a significant source of friction between Iran and the United States. In a rare agreement mediated by Qatar between the bitter rivals, five American prisoners were exchanged for five Iranian prisoners jailed in the United States on Monday and $6 billion in frozen Iranian cash was also unfrozen.