In a victory for the Trump administration, the House on Thursday approved legislation to renew government surveillance powers while voting down new limits on how authorities can use the information that is collected.

Just a few hours before the vote, President Trump roiled the waters by sending out a tweet that appeared to contradict his own administration's opposition to the changes, which were offered by Rep. Justin Amash (R-Mich.).

That amendment failed by a vote of 233-183.

" '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.

The White House had said it supported the underlying surveillance bill but strongly opposed Amash's amendment.

Trump later clarified that he "has 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."

After rejecting Amash's amendment, the House passed an underlying bill backed by members of the House Intelligence and Judiciary committees that renewed the NSA's warrantless surveillance program with just a few small changes.

The bill, passed by a vote of 256-164, now heads to the Senate, which is expected to swiftly take up and pass the measure before the surveillance program expires on Jan. 19.

At issue is a law passed in 2008 - known as Section 702 of the Foreign Intelligence Surveillance Act (FISA) - that allows the NSA to collect texts and emails of foreigners abroad without an individualized warrant, even when they communicate with Americans in the U.S.

Throughout the fall, privacy advocates on Capitol Hill pushed for changes to the law that critics say are necessary to ensure Fourth Amendment protections for people swept up in surveillance. The push seemed to gain some momentum even over the objections of the Trump administration.

The intelligence community sees the law as one of its top tools to identify and disrupt terror plots and even amongst reform advocates, there is no appetite to see the program lapse entirely.

But House Judiciary Chairman Bob Goodlatte (R-Va.) has long said a clean reauthorization of Section 702, without any changes, would not pass the House, where the powerful Freedom Caucus has banded together with privacy-minded Democrats to advocate for tighter restrictions on how government investigators can use data gathered under the program.

The issue was catapulted onto the front page amidst the controversy over "unmasking." Republicans have long speculated that former national security adviser Michael Flynn was caught up in 702 surveillance and inappropriately unmasked by Obama administration officials.

That process, surveillance experts say, is not directly related to congressionally dictated 702 authorities - it's governed by administration regulations.

"There are FISA issues swirling around that have absolutely nothing to do with 702," Rep. Mike Conaway (R-Texas) said before the vote. "Those are being used by opponents, those who want it to go dark, in a perfectly legitimate debate technique to try to muddy the waters."

Updated at 11:56 a.m.