Iran was generally neutral-to-friendly toward the US until the 1951 rise to power of the pro-Soviet Prime Minister Mohammad Mosaddegh, who demoted the pro-US Shah to a marginalized ceremonial monarch.
Ambassador (ret.) Yoram Ettinger -- During the period 1953-1978, following the dismissal of Mosaddegh, and the restoration of the executive power of the Shah, Iran functioned as one of the US’ most trusted Cold War allies, a Major Non-NATO Ally of the US and “the American Policeman of the Gulf.”
This strategic honeymoon was terminated by the 1979 Islamic Revolution, which transformed Iran into a clear and present threat to the US, the chief global epicenter of civil wars, anti-US terrorism, drug trafficking and money laundering in the Middle East, Africa and Latin America, with a multitude of terror sleeper cells on US soil.
In the long run, US policy in the Middle East is challenged by alliances with Middle Eastern Arab/Muslim countries, which are as jerkily spiral as has been the volcanic nature of the Middle East since the 7th century: