The Senate voted Thursday to approve a controversial government surveillance law, sending the House-approved measure to President Trump’s desk.

The chamber voted 65-34 to reauthorize Section 702 of the Foreign Intelligence Surveillance Act, which lets intelligence agencies collect information on foreign targets abroad, before its expiration Friday night.

“Let’s be very clear about what Section 702 does: It enables our intelligence community to collect communications from foreign terrorists, on foreign soil, who threaten America and our allies,” Senate Majority Leader Mitch McConnell, R-Ky., said in a statement Thursday. “Make no mistake, Section 702 does not allow the targeting of American citizens. Nor does it permit the targeting of anyone –no matter their nationality—who is known to be located here in the U.S.”

He added: “The men and women we trust to protect this country say this capability is essential to their missions….We need our armed forces and intelligence community to protect us. And they need us to give them the tools to do it.”

The bill allows the FBI to continue querying a key database, using search terms, for information on Americans. But in an important tweak, it would require investigators to get a probable cause warrant if they want to view the actual content of those communications.

The House passed the same measure last week, by a 256-164 vote, amid mixed messages from President Trump about his support.

The morning of the House vote, Trump tweeted suggesting 702 was used to “badly surveil and abuse” his campaign based on the “pony” Trump dossier.

“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?” Trump tweeted last week.

His tweet caused confusion on Capitol Hill over the administration’s position on the reauthorization, as the White House and Cabinet members had previously said they would support it.

Trump's opposition didn’t last long, though, as he followed up with a tweet clarifying that he has sought changes to the law and voiced support for the program in general.

HOUSE VOTES TO RENEW FISA PROGRAM, FOLLOWING MIXED MESSAGES FROM TRUMP

“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!” he tweeted.

White House Chief of Staff John Kelly clarified the gap in the president’s conflicting tweets.

“I spoke to the president about the issue. It’s an important issue. It’s the FISA reauthorization and it’s very, very important to law enforcement,” Kelly said in an exclusive Wednesday interview on “Special Report.” “He has strong feelings on personal privacy. He sent out the first tweet, and sent out the second tweet.”

Kelly was asked whether he spoke to the president in between the tweets to explain the program.

“He and I talk constantly. Weekends, mornings, late at night. We talk constantly. He bounces ideas off of me. I’m very proud of the fact that he respects my opinion, but again, he is the president of the United States,” Kelly said. “He’s got his own way of doing business. But again, I see a man who can change his mind when the facts and data and staff ... bring him to a different conclusion.”

Fox News’ Alex Pappas, Adam Shaw and Chad Pergram contributed to this report.