The fixed election in Iran, with its blatant manufacture of millions of votes and/or assignment of votes without regard to ballots, gives rise to the question: “Could it happen here?” The short answer is “No”, the longer answer is “No, except when it is very close.”
Unlike Iran, we don’t have a direct election for President; we have our idiosyncratic Electoral College system. The EC is often criticized precisely on this point, and the fact that it occasionally results in an odd outcome. It is, instead, the solid basis for our 220 years as a republic.
The EC provides several levels of protection to the legitimacy of our election. It is first and foremost a firewall. The system distributes vote counting to the states. Since states only award electoral votes, padding state totals doesn’t do anything. Since such shenanigans are possible only when one has complete control over the counting, it usually doesn’t affect the state’s outcome, either.
Only when the state total is very close and one controls a sizable portion of the state can the outcome be swayed without notice. And, in the end, you have only changed one state’s electoral vote; forty-nine to go. So, it also takes a close federal election to matter. Chicago 1960 (successful fraud) and Florida 2000 (take your pick) are possible examples where the system failed.
Secondly, the system partitions any needed recounts to one or a few states. Election 2000 is a perfect example. The federal margin (~500K votes for Gore), the Florida margin (537 votes for Bush) and the New Mexico margin (267 votes for Gore), along with close votes in Oregon and Wisconsin would have meant a nationwide recount. If you think the Florida recount was bad, multiply that by 50. Given Bush v Gore, you have to count them all again; can’t cherry-pick.
Third, the system provides a tie-breaker. Tight elections (margin less than, say, 1%) go the the candidate who won the most states. This is part and parcel of the Senate-membership deal struck in Philadelphia in 1787, and not at all an accident. This also adds to the difficulty in rigging an election, as it is the large metropolitan areas where machine control is most likely, and they cannot easily get past the dead hand of the two base EC votes per state.
In short, it could only happen here if we reformed the Electoral College to be more “democratic.”