Also let's not forget that Iran did have a democratically elected government and prime minister. Until it was toppled by western powers for plans of nationalising the oil that is. Replace him with an agreeable puppet dictator and watch it backfire in 79. Diplomacy!
I mean, it's a little more complicated than that.
In 1951, the shah tried to force the new oil agreement with the AIOC through the Majlis, and brought in General Razmara as prime minister to do the job. Razmara went beyond his brief, openly threatened a white revolution, and managed to get himself assassinated in March. The Razmara assassination, combined with popular street demonstrations against the oil deal from sources as disparate as the socialist Tudah party and clerics led by Ayatallah Kashani, frightened the Majlis into swinging the other direction. They wrote up a bill to nationalize the oil industry, but couldn't find anyone to implement it other than Muhammad Musaddiq, so they convinced the shah to name him prime minister.
Musaddiq was only "kind of" a democratically elected leader. He was
appointed based on his ability to command a majority for his policies in the Majlis, and the only way he could do that was by seating a quorum of 69 members, dominated by his most likely allies, and refusing to seat many members elected by rural constituencies. (By the way, that's a real
nice quorum number.) This meant that the people who could demonstrate in the streets - the people that had scared the Majlis into making Musaddiq PM in the first place - were the ones who were overrepresented in the new legislature. Even so, the requirement for a quorum and Iran's predominantly rural weighting in the legislature meant that even this rump Majlis had an awful lot of representatives for conservative landowning interests and Shi'a religious constituencies. They supported a new structure for Iran's oil exports, but they disliked the economic difficulties introduced by the deadlock (historians disagree on the reality of the economic dislocation but seem fairly united on the fact that Iran's political classes believed it was happening) and they disliked his land-reform policies. Musaddiq, who had been out of power for decades, was probably too rash in his decision to move quickly on a raft of reforms that did not have a clear constituency, and was unquestionably bad at managing the legislature. As disillusionment with the government's policies grew, Musaddiq could no longer count on a majority even in this rump Majlis. In the summer of 1952, the shah canned him in favor of his predecessor, Qavam, who promised to reverse nationalization and pass the agreement with the AIOC. Tudah and the nationalist parties unleashed more street demonstrations, which frightened the shah into bringing Musaddiq back with emergency powers and control over the military.
Effectively, Musaddiq knew that he couldn't govern through Iran's elected institutions and sought to employ popular violence as a pressure mechanism to achieve his goals. This culminated in August 1953 when he staged a national popular referendum to choose between his government or the Majlis. The results were not by secret ballot (voting against the Musaddiq government had to be done in a separate tent) and the prime minister used the military to try to intimidate voters into siding with him. He won with over 99% of the vote, a farcical result widely criticized in the West. Less than two million people voted out of Iran's population of 18 million. Musaddiq
did have a lot of popular support, obviously, and the Western media and governments had an obvious interest in trying to delegitimize the results of the referendum, but it still
wasn't legitimate. Even Musaddiq's modern supporters admit that the referendum was a bad move. The shah, claiming that Musaddiq planned to make himself a dictator, dismissed him and appointed General Zahidi prime minister in his place. Musaddiq refused to go and Tudah started more antiroyalist demonstrations; the shah panicked and fled the country. Musaddiq immediately backstabbed Tudah by ordering the army to clear the streets and arrest prominent Tudah leaders. Although he was probably right that Tudah was planning a coup to replace
him, this further eroded his claims to popular support and left him extremely vulnerable to the army countercoup on three days later.
The countercoup's wheels were greased by American money, which helped start anti-Musaddiq demonstrations during the crucial three days of the prime minister's dictatorship, and which convinced more army officers to join the coupists. The Americans also helped the shah overcome his fear of Musaddiq that led him to panic and flee Iran in the first place. But fundamentally, Musaddiq's regime, which had never been based on a strong popular support and which relied on short-circuiting the only democratic institutions that Iran had, was extremely vulnerable to any sort of challenge, so long as the challenger could keep his nerve. (The shah, of course, was fantastically bad at keeping his nerve, as the 1979 revolution showed.) By 19 August 1953, Musaddiq had successfully alienated the shah, most of the prominent Shi'a clerics, the country's landowning class, Tudah and the urban socialists, and the army (except for those officers he had promoted himself). American money and the CIA played a big role in unseating him, but they probably just made things happen
faster.
Musaddiq was a populist, undoubtedly, and a nationalist, who opposed Western economic imperialism, and the Americans played a role in bringing him down that eventually led to significant blowback. But describing him as "democratically elected" is a bit much. He was as democratically elected as Otto von Bismarck in that he was appointed to control the legislature and garner majorities in it. But he had no party constituency and he was not electorally responsible to the legislature, and those were two of the reasons why he fell.