A bill renewing a critical foreign intelligence collection program has cleared the Senate and House. 

The Senate on Thursday passed what is known as Section 702 of a program that allows spy agencies to collect information on foreign targets abroad. The House passed the bill earlier this month.

The vote Thursday was 65-34 to reauthorize a program dubbed the "holy grail" because it lets U.S. spy agencies conduct surveillance on foreign targets abroad. Senators Dean Heller (R-NV) and Catherine Cortez Masto (D-NV) both voted to approve the bill. 

Some lawmakers wanted the bill to strengthen protections for Americans whose communications are inadvertently vacuumed up in the foreign surveillance.

The bill lets the FBI keep scanning the intelligence database, using search terms, for information on Americans.

But it would require a warrant to view the actual content in cases unrelated to national security. The bill's opponents say the warrant requirement would rarely kick in and more is needed to protect Americans' communications.

President Trump previously tweeted about the program. He referred to the Foreign Intelligence Surveillance Act, which lets spy agencies collect information on foreign targets abroad. 

Trump said: "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?"

Attorney General Jeff Sessions issued the following statement:

“Today's vote to reauthorize Section 702 of the Foreign Intelligence Surveillance Act is crucial to allowing us to continue to gather intelligence on foreign terrorists overseas and foil potential plots against Americans abroad and at home. I would especially like to thank the Senate and House leadership on both sides of the aisle, as well as the bipartisan efforts from those leaders on the Senate and House Intelligence and Judiciary Committees that supported and helped pass this critical legislation that gives us the tools to continue to keep the American people safe.”

U.S. Senator Catherine Cortez Masto released the following statement:

“The safety of Nevadans and all Americans is a top priority for me. Our intelligence agencies must have the appropriate tools to protect our country from terrorist threats. My vote to reauthorize Section 702 of FISA reinforces my commitment to national security and the safety of Nevada and the families, friends, neighbors, and communities that call our state home. This bill also takes notable steps to protect civil liberties, including by expanding Congressional oversight of the program. While it is not a perfect bill, on balance the legislation will give our law enforcement and intelligence community the tools they need to keep us safe, while creating the avenues Congress needs to continue to keep a watchful eye on the program and how it is being used. I look forward to working with my colleagues in the coming years to ensure our oversight is continuous and rigorous. I will continue to do everything I can to ensure that our communities remain secure and that appropriate protections for American civil liberties are in place.”

(The Associated Press contributed to this report.)