In general an election is legitimate if it satisfied all the conditions that were prescribed in the document that specified the election, such as in the Constitution. This means for example a sufficient voter turnout (in the US this would mean at least 1 voter in a number of states sufficient to provide an majority in the electoral college), lack of fraud (all the votes were cast according to the law) and no other illegal activity, such as selling votes, etc.