Elections are generally associated with democracy, but [they do happen in dictatorships as well](https://politics.stackexchange.com/q/2918/2130).  The difference is that the election result in a dictatorship is manipulated to confirm the current government's power.   This could be by making sure there is no opposition, not using secret ballots and intimidating voters, ballot stuffing, or by outright making up results.  But all of these require the government to already be in power, in order to manipulate the vote to stay in power.

Are there any historical examples of someone manipulating a vote to _gain_ power in the first place?  Or do dictators have to gain power some other way (coup, legitimate election, invading army, etc) first, and only then manipulate things to keep it?