Voters have rejected a key Republican candidate, despite the Tesla chief pouring millions into the election.