My intense immersion in Iranian politics had left me with the conviction that things could have turned out differently from the results of U.S. President Jimmy Carter's benign and optimistic approach to Khomeini's revolution.
Likewise, my experiences in Iran produced lessons that are still valid for dealing with the mullahs more effectively than what passes for foreign policy under President Barack Obama: Expressing respect for their culture and apologizing for past American actions.
Moreover, those lessons could apply to the current Egyptian situation as well.
Events moved rapidly after my arrival. While Khomeini's incendiary sermons were broadcast from the minarets, the shah, under American direction, liberalized the media, which in turn and unfortunately did its best to undermine the government.
Things were unfolding quickly, and circumstances allowed me to make several high-level recruitments. One was an army general and another was a government official who also was an influential businessman.
According to the general, the army's leadership was waiting for clear orders from Washington. Carter had sent U.S. Air Force Gen. Robert E. Huyser, deputy EUCOM, to Tehran with the mission, according to his memoir, to stabilize the situation by using his personal contacts in the Iranian officer corps.
The military leadership had expected Huyser to give the green light for a military coup. Instead, what they heard was that Carter wanted the shah to leave the country to make way for Ayatollah Khomeini.
The generals were convinced that a show of force would intimidate the mullahs back into their mosques. Yes, my agent admitted, there might be casualties. But a confrontation would save the country. Lacking specific direction from the shah, or encouragement from the United States, the military stayed neutral.
My second agent had a similar but less-bloody recommendation: a large and peaceful demonstration of public support for the shah to blunt the opposition. Thousands of people in the city, he said, supported the shah but they needed encouragement to prove they weren't alone.
That advice fell on deaf ears with Ambassador William Sullivan, who gave short shrift to the peaceful demonstration idea, convinced that the disturbances were only bumps in the road and things in Iran would return to normal soon. Similarly, the CIA said little, deferring to the U.S. Department of State and not wanting to be accused of trying to repeat the 1953 coup.
Would demonstrations in support of the shah have stopped the opposition's momentum? Would I have received a hysterical phone call from an Iranian air force pilot, whom I had also recruited, telling me that all members of the military were being ordered back to their barracks, thus leaving the field to the opposition's militias? Or was it already too late?
I don't think so. Demonstrations probably would have delayed or prevented entirely the first takeover of the U.S. Embassy in February 1979. And, if that first invasion of the American compound hadn't taken place, there wouldn't have been a precedent of invading U.S. territory without consequences, as happened in November.
As I told Harold Saunders, the Department of State's assistant secretary for Near Eastern affairs, in early March 1979 that first takeover only encouraged revolutionary groups to do it again unless the embassy was better protected.
Institutional blindness at State wasn't the only U.S. shortcoming in Iran at the time. My own agency also suffered from it by neglecting its traditional role of collecting information on all power centers in the country.
Now, a new Iranian president has been elected and characterized as moderate by the Western media. Washington probably will want to accord Hassan Rouhani a grace period to see if he will bend on the nuclear issue more than his predecessor.
Where Mahmoud Ahmadinejad was a Bad Cop, we hope Rouhani will be the Good Cop. Unlikely. For one thing, the Persians have always been tough negotiators. For another, Rouhani was a member of the Iran National Security Council when it approved the bombing of the Jewish Cultural Center in Buenos Aires and the bombing of the Kobhar towers in Saudi Arabia, which killed 19 U.S. servicemen.
Washington shouldn't be deluded into believing Rouhani's election changed Iran's DNA, which it largely shares with the Muslim Brotherhood. After contributing to Hosni Mubarak's ouster in 2011, the Obama administration encouraged early elections in Egypt. Like Carter, Obama misperceived the movements that unseated the country's leadership. In both cases, the result was less democratic and bloodier.
That the Muslim Brotherhood's Mohamed Morsi has turned out to be a totalitarian, anti-Christian, misogynistic and inept administrator shouldn't have come as a surprise; his election campaign explicitly promised to bring Shariah Law to Egypt.
As in the Iranian case, where Ayatollah Khomeini said he didn't bring revolution to Iran in order to lower the price of melons, Morsi's agenda didn't include the economic well being of the Egyptian population.
After World War II, the United States prevented both Italy and France from becoming communist by subsidizing more moderate parties. We should also be able to prevent the Middle East from falling to another totalitarian ideology, this one a radical and cruel version of a way of life that might fit the needs of seventh-century desert nomads but which is irreconcilable with the 21st century.
Almost 100 years after Kamal Ataturk began the westernization of Turkey, that country is currently being led by an Islamic party but is a member of the international system of nations; it could be a model for other countries.
Like communism, radical Islam will not go away by itself. It is in the interest of the West, and the United States in particular, to help the populations of the Middle East to build alternative solutions. Passive observation of events in the hope that everything will turn out all right is likely to create other theocratic republics and, if Iran is allowed to go nuclear, so will they.
(Andre Le Gallo is a former CIA officer who was chief of station in several countries and National Intelligence Officer for Counter-terrorism. He is the author of "The Caliphate" and "Satan's Spy."
(United Press International's "Outside View" commentaries are written by outside contributors who specialize in a variety of important issues. The views expressed do not necessarily reflect those of United Press International. In the interests of creating an open forum, original submissions are invited.)