Congress rejected new limits on surveillance that sweeps in Americans after Donald Trump roiled debate with a series of contradictory tweets assailing a programme his administration is on the record supporting.

A provision of the Foreign Intelligence Surveillance Act (FISA) which allows intelligence agencies to gather communications from foreign targets without obtaining warrants, has spurred a debate over the balance between national security and privacy. With the broader programme up for renewal, a bipartisan group of politicians proposed requiring warrants when surveillance vacuums up messages Americans send or are mentioned in.

An amendment imposing that mandate failed in a House vote as representatives approved the larger programme with minimal changes. On the eve of the vote, the White House sent out a statement saying it “strongly opposes” the proposed surveillance limits.

“This amendment would re-establish the walls between intelligence and law enforcement that our country knocked down following the attacks of 9/11 in order to increase information sharing and improve our national security,” the statement said.

The White House had thrown its support behind the surveillance provision on similar grounds, with multiple administration officials calling for it to be made permanent, but Mr Trump sowed confusion by attacking the measure and then seeming to backtrack.

After initially decrying the programme on Twitter as having been used to “so badly surveil and abuse the Trump Campaign,” he later said that “today’s vote is about foreign surveillance of foreign bad guys on foreign land”.

“We need it! Get smart”! Mr Trump said.

Those divergent responses prompted some members of Congress to question whether Mr Trump understood a controversial national security tool that was on the verge of being renewed.

Governmental surveillance Show all 8 1 /8 Governmental surveillance Governmental surveillance Governmental surveillance Detachment 3, Air Force Flight Test Center #2, Groom Lake, Nevada Trevor Paglen Governmental surveillance Governmental surveillance Black Site, Kabul, Afghanistan Trevor Paglen Governmental surveillance Governmental surveillance A drone hovering in the skies over Dande Darpa Khel, North Waziristan Trevor Paglen/Noor Behram Governmental surveillance Governmental surveillance Hide and seek: the tiny dots visible in this image is a Reaper drone Trevor Paglen Governmental surveillance Governmental surveillance National Reconnaissance Office Ground Station, New Mexico Trevor Paglen Governmental surveillance Governmental surveillance N5177C at Gold Coast Terminal, Las Vegas. The plane is one of those used to shuttle people to work at classified military installations in the Nevada desert Trevor Paglen Governmental surveillance Governmental surveillance The Salt Pit, previously secret CIA prison, north-east of Kabul, Afghanistan Trevor Paglen Governmental surveillance Governmental surveillance Remote: Paglen took this photograph of Open Hangar in Nevada using a high powered telescope Trevor Paglen

House Minority Leader Nancy Pelosi and Adam Schiff of California, the top Democrat on the House Intelligence Committee, suggested that the House should hold off on voting until representatives had more clarity on Mr Trump's tweets.

“FISA is something the President should have known about long before he turned on Fox this morning,” Senator Mark Warner of Virginia, the senior Democrat on the Senate Intelligence Committee, said on Twitter.