The U.S. Senate on Thursday voted 65-34 to reauthorize controversial foreign surveillance powers, sending the bill to President Trump's desk.

Section 702 of the Foreign Intelligence Surveillance Act (FISA), which was passed under former President George W. Bush in the aftermath of Sept. 11, 2001 terrorist attacks, was set to expire Friday night. Some Republicans — such as Rep. Justin Amash, R-Michigan — along with many Democrats opposed reauthorizing section 702, arguing the executive branch's surveillance powers are too expansive, and should include additional privacy protections.

However, the bill that ultimately passed leaves the program roughly as-is. Section 702 allows the government to intercept the electronic communications of non-U.S. persons, and has long been criticized by civil liberty advocates.

Get Breaking News Delivered to Your Inbox

Sen. Richard Burr, the Republican chairman of the Senate Intelligence Committee, praised the bill's passage.

"Today, the Senate took this important step in reauthorizing what I believe is our single most important national security tool," Burr said. "This bill will help us to fulfill our most important duty as senators: keeping Americans safe. Section 702 of the Foreign Intelligence Surveillance Act has been reviewed time and again by both the courts and Congress, and has been found to be not just constitutional, but vital to our country's defense. I look forward to the president signing this legislation without delay."

Mr. Trump is expected to sign the bill, although he sent discussions about section 702 into chaos last week when he suggested on Twitter that the program was used by the Obama administration to spy on his campaign. The tweet seemed to suggest the president was against the very bill most of his party was trying to pass.

“House votes on controversial FISA ACT today.” This is the act that may have been used, with the help of the discredited and phony Dossier, to so badly surveil and abuse the Trump Campaign by the previous administration and others? — Donald J. Trump (@realDonaldTrump) January 11, 2018

But Mr. Trump — after speaking with chief of staff John Kelly and others — followed that surprise tweet by saying the program is vital to national security.

With that being said, I have personally directed the fix to the unmasking process since taking office and today’s vote is about foreign surveillance of foreign bad guys on foreign land. We need it! Get smart! — Donald J. Trump (@realDonaldTrump) January 11, 2018

President Trump is expected to sign the reauthorization before section 702 expires.