U.S.-Iran relations have been increasingly tense since Donald Trump took office, but the president’s decision to kill Maj. Gen. Qasem Soleimani has led the U.S. and Iranian governments to inch closer to war than ever before — Iran reportedly retaliated by striking multiple Iraqi bases housing U.S. troops early Wednesday. The growing conflict has ramifications for the entire Middle East. But none of it was inevitable. In fact, Iranians once saw Americans as friends, and the two nations became close allies by the mid-20th century.

Although the Islamic Republic of Iran has not been blameless for worsening relations since its creation in 1979, the United States bears most of the blame for the two nations’ dramatic transformation from allies into enemies.

The United States and Iran had their first diplomatic encounters in the 1850s, which led to a treaty of friendship. The nations’ relationship remained friendly but distant through the early 20th century. Multiple times in the late 1800s and early 1900s, Iran requested U.S. assistance in fending off Britain’s and Russia’s increasing attempts to dominate Iranian affairs. Yet before World War II, the United States declined, following a policy of strict neutrality and noninvolvement in Iran’s internal affairs. Nonetheless, the U.S. government worked to maintain friendly relations, built closer economic ties and supported the activities of U.S. citizens and businesses in Iran.

Despite the U.S. government’s aloofness, Iranians developed a generally positive view of the United States and Americans. The American Revolution offered inspiration for Iranian nationalists, and the United States had not attempted to dominate Iran, unlike Russia and Great Britain. U.S. citizens also fostered goodwill in Iran: American Protestant missionaries built hospitals and schools across Iran that provided much-appreciated services, and missionary doctors provided medical services to Iran’s royal family.

In 1909, a 24-year-old American missionary named Howard Baskerville died fighting alongside Iranian constitutionalists — who fought for democracy and against British and Russian imperialism. It was Iran’s first revolution and the Islamic world’s first mass pro-democracy movement, and Iranian constitutionalists declared Baskerville a hero. Two years later, in 1911, Iran’s new constitutionalist government appointed the 34-year-old American W. Morgan Shuster to be the nation’s treasurer-general. Shuster and a small team of Americans worked to help Iran reorganize its finances, and Shuster was an outspoken defender of Iran.

Unfortunately, Britain and Russia could not tolerate the possibility of a financially independent Iran. Russia invaded in late 1911, closed down Iran’s parliament, and forced Shuster’s ouster. Nevertheless, Shuster’s sincere efforts to help Iran, along with Baskerville’s earlier sacrifice, caused many Iranians to see Americans as friends. For this reason, Iran again hired Americans as financial advisers in the 1920s and 1940s.

During World War II, Americans provided military advice and other assistance, and the United States once again won goodwill when President Harry Truman helped Iran ensure that British and Soviet troops fully withdrew from Iranian soil in 1946. By the start of the 1950s, Iran was well on its way to building a strong parliamentary democracy, and the increasingly close U.S.-Iran relationship had a strong foundation.

The start of the Cold War and the U.S. policies that sprung from it caused things to go awry. Iran’s democratically elected prime minister, Mohammad Mossadegh, nationalized his nation’s oil industry in the early 1950s, threatening Britain’s historical monopoly over Iran’s oil. In response, the United States and Britain staged a coup that overthrew Mossadegh in 1953. Unlike Truman, who rejected the option of a coup against Mossadegh, President Dwight Eisenhower was concerned about Soviet influence in Iran, worried that other developing countries might get ideas about nationalizing their natural resources and eager to experiment with CIA covert operations. His decision to greenlight the coup forever changed Iranian history — and Iran’s relationship with the United States.

The coup allowed Iran’s king, Mohammad Reza Pahlavi, to refashion himself from a weak constitutional monarch into an absolute ruler. The history of his rule after 1953 is complicated and remains controversial. What is clear is that the coup led many Iranians to question the shah’s legitimacy.

His attempts throughout the 1960s and 1970s to strengthen and modernize his nation failed to win him the love of his people, and economic stratification in Iran stoked discontent by the 1970s. Many Iranians also saw the shah as an American puppet, and his authoritarian government — especially its suppression of free speech and use of imprisonment and torture against political dissidents — contributed to the popular discontent that ultimately erupted in 1979 and led to his ouster.

When President Jimmy Carter toasted the shah’s “great leadership” in making Iran an “island of stability” on New Year’s Eve in 1977, it underscored the United States’ support for the autocrat, thanks to Iran’s crucial strategic location. Yet Carter’s praise for the shah rankled Iranians, who saw him as a hypocrite for championing human rights elsewhere but not in Iran. Thus, the U.S. role in the 1953 coup, combined with American backing for the shah, sowed the seeds of anti-Americanism in Iran that burst forth during the revolution.

Since 1979, the United States and Iran have been enemies. Iran held U.S. diplomats hostage for 444 days beginning in November 1979. Iran’s leaders referred to the United States as the “Great Satan.” The United States backed Iran’s enemy, Saddam Hussein, during the bloody Iran-Iraq War of 1980-1988. President George W. Bush famously declared Iran part of an “axis of evil” after 9/11. American leaders have accused Iran of supporting terrorist groups in the Middle East, while Iran has charged the United States with imperialism. U.S. support for Israel also remained a source of enmity. Tensions flared many times between 1979 and today, as the two countries competed for influence in the Middle East and nursed hard feelings over the past.

Yet the 2015 Iran nuclear deal brokered by the Obama administration offered an opening that promised the possibility of improved relations. The U.S. and Iranian governments engaged with each other directly for the first time since cutting off diplomatic relations over the hostage crisis, and the agreement increased the likelihood of future negotiations.

The rapid escalation in tensions that led to the current moment of potential war was entirely manufactured by the Trump administration. President Trump chose to abandon the nuclear deal in 2017-2018, slap punishing sanctions on Iran (which mainly hurt the Iranian people, who already suffer under their repressive government), appoint Iran hawks to high-ranking positions, impose a “Muslim ban” that keeps Iranians from even visiting the United States, deploy inflammatory rhetoric, threaten airstrikes and, finally, perpetrate an act of war by killing one of Iran’s top government officials, Soleimani.

Trump’s hard-line posture on Iran is a remarkable exception to his open admiration for and courting of authoritarian leaders elsewhere — notably Russia’s Vladimir Putin and North Korea’s Kim Jong Un. Ironically, Iran may have been the authoritarian country with which the United States had the greatest potential for rapprochement. That possibility is gone now. Iran’s government remains deeply unpopular with its own people, but its leaders have shown a brutal determination to hold on to power by any means necessary. Its bloody crackdown on protests since November are evidence of this. The domestically precarious Islamic Republic doesn’t want a war with the United States. It will, however, defend itself, and it has the military means to do so — as it proved with its rocket attacks on the bases in Iraq.

The war of words and violence between the two governments that has ensued since the killing of Soleimani may easily escalate to a shooting war in the coming days. That war will be bloody, long and painful for everyone involved. The great tragedy if that occurs is that the war will have been entirely avoidable. And it will destroy the possibility of ever returning to a time of U.S.-Iran goodwill.