The parliament while Mossadegh was prime minister was democratically elected (though Mossadegh was appointed by the Shah, per the constitution). But by the time he was removed, Mossadegh had dissolved the parliament and was ruling by fiat based on a rigged plebiscite (his administration claimed the result was 99.9% in favore of the plebiscite[1]).
The U.S. certainly conspired with the Shah to oust him, but it seems like their initial plans failed (certainly, the plotters seemed to think it failed), and royalists in the Iranian military were ones who ultimately removed him.
The whole thing was a fairly complex situation that tends to get reduced to a simplistic soundbite with little connection to what actually happened.
[1] https://www.nytimes.com/1953/08/04/archives/mossadegh-gets-9...