WASHINGTON — The Senate on Thursday voted to extend by six years a law that authorizes the National Security Agency’s warrantless surveillance program, essentially ending a cycle of debate over wiretapping and privacy that began with the leaks in 2013 by Edward J. Snowden, a former intelligence contractor.

The vote, 65 to 34, approved sending to President Trump a bill to keep through 2023 an activity that traces back to a once-secret program created by the George W. Bush administration following the terrorist attacks of Sept. 11, 2001. Congress first legalized it in 2008 by enacting a law called Section 702 of the FISA Amendments Act.

Under Section 702, the government, without a warrant, may collect from American companies, like AT&T and Google, the emails, texts, phone calls and other private messages of foreigners abroad — even when those targets communicate with Americans.

Congress last extended that law without changes in 2012. But after Mr. Snowden’s leaks in 2013, a bipartisan coalition of civil-liberties-minded lawmakers pushed to impose far more sweeping warrant requirements on queries for Americans’ information that was swept in by government surveillance.