The 17th Amendment to the Constitution was proposed by Congress in 1912 and promptly ratified by the states, shifting the power to elect senators from the state legislature to the people of the state. This came after nearly a hundred years of efforts to do so, all of which had been ignored in the Senate.
The idea initially was that the House, directly elected by the people, would represent them, and the Senate, a cooler and more temperate body, would represent the states. While the loose association of the Articles of Confederation was undesirable, and on the delegates' minds in the Constitutional Convention of 1787, many of them feared that the states would be swallowed up by the federal government, and their rights and powers usurped, so they divided the Congress in part to assuage that concern.
How did that change? Why did the state legislatures want to give up that power, and how did anyone persuade the Senate to go along with it?
It seems odd at first, but the momentum began with the states; from 1891 to 1905, 20 different states deadlocked on 46 senatorial elections. Three years later, Oregon enacted open primaries: the legislature would still have the final choice, but the people of the state chose the nominee for each party. Other states followed that example, with some opting for the same primary approach, and others deferring the entire election to the people.
The state legislatures being the impetus isn't so surprising, actually; since they were elected directly by the people, they could in theory reflect the people's wishes. In addition, while electing a senator only had to be done twice in six years, thus ideally occupying very little of their time, it became a major issue, overshadowing the more boring things like water use, mineral rights, tourism, that made up more of the business they wanted to conduct. Sparked in part by William Randolph Hearst's enthusiastic promotion of the idea, state legislatures began reforming their own senatorial elections, and calling for an amendment requiring popular election.
The beginning of the end for legislative elections came in 1910: 31 states passed resolutions petitioning Congress to propose a constitutional amendment, and ten senators opposing reform were defeated in their reelection attempts. The majority of the Senate that still didn't like the idea saw the 27 states calling for a constitutional convention, with four more ready to do so, and finally, grudgingly, approved the 17th amendment, fearing the drastic changes that might threaten their privilege in a convention they could not influence.
The first draft prohibited federal intervention in cases of racial discrimination against voters; Southern Representatives didn't want the gubmint forcing them to let folks other than whitey into the polls. The Senate passed a version without that rider, and the House went along with it, sending it out to the states in May 1912. Less than a year later, the 36th ratification came in, and the Senate became a body fully elected by the people.