Senators are elected by popular vote in each state. The candidate who receives the most votes wins the election, though in some states, when no candidate receives at least 50 percent of the vote, the candidates with the two highest vote counts compete in a runoff to determine the winner.
Direct election of senators began in 1913. Prior to that, senators were chosen by the legislature of each state, as initially prescribed by the U.S. Constitution. The process was changed to direct election due to various problems and controversies arising from legislative appointment. The state of Indiana in the 1850s is illustrative of the type of problem that led to the change. Anti-slavery Republicans in the northern part of the state clashed with pro-slavery Democrats in the south. This resulted in the state going without a senator for two years. Bribery was also a major issue.
The 17th Amendment mandated popular election. It also gave the governor of each state authority to appoint a replacement should a senate seat become vacant. The replacement senator serves the remainder of the vacating senator's six-year term. At the end of the term, the replacement senator is eligible to run for a full six-year term.