The President of the United States is not directly elected by the population, but by the Electoral College. Each state is assigned electoral votes based on the number of senators and representatives that each state has in Congress.
Each state has two senators. The number of representatives is determined by the state's population but is never less than one. Thus, small states with a small population are overly represented in the Electoral College. One candidate wins all of the electoral votes in a state. The Electoral College meets on the first Monday after the second Wednesday in December. Their votes are then counted again in the presence of the Joint Meeting of Congress on the sixth day of January to certify the returns.
The candidate that wins over 50% of the electoral votes becomes President of the United States. If no candidate wins the majority of electoral votes, the House of Representatives decides who wins. The House of Representatives votes by state. In this case, every state in the House of Representatives gets one vote.