In three hours, the House was set to vote on controversial legislation renewing the National Security Agency’s warrantless surveillance program.

The White House was actively whipping votes on the bill, which would extend a program that senior officials say is critical to keeping America safe from terror plots. Getting the program renewed with as few changes as possible had been the intelligence community’s No. 1 legislative priority for the past year.

Then, at 7:33 a.m., President Trump Donald John TrumpObama calls on Senate not to fill Ginsburg's vacancy until after election Planned Parenthood: 'The fate of our rights' depends on Ginsburg replacement Progressive group to spend M in ad campaign on Supreme Court vacancy MORE tweeted.

ADVERTISEMENT

“‘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 tapped out.

Suddenly, Capitol Hill was thrown into confusion before what was already expected to be a tight vote.

After months of lobbying by the administration for a renewal of the surveillance program, it appeared that the president himself was throwing his weight behind an amendment to impose new privacy limitations on the government.

Supporters of the amendment immediately blasted out the tweet to rally support for the proposal. Democrats launched an ill-fated effort to pull the underlying bill from the floor. Members walking onto the floor to vote, asked for their predictions, threw their hands up and said, “No idea!”

“There were people on the fence, there were friends of mine on the fence that I’ve been working — when that first tweet came out, I got a couple texts from some of my friends saying ‘I’m voting no, because if he doesn’t care I don’t care,’” said Rep. Tom Rooney Thomas (Tom) Joseph RooneyHouse Dem calls on lawmakers to 'insulate' election process following Mueller report Hill-HarrisX poll: 76 percent oppose Trump pardoning former campaign aides Dems fear Trump is looking at presidential pardons MORE (R-Fla.), a member of the House Intelligence Committee who backed the underlying legislation.

An hour and a half later, Trump issued a second tweet clarifying his position.

At the time, Republicans were holding a contentious meeting on the bill behind closed doors. The House Freedom Caucus and a few other privacy-minded members have been fiercely opposed to renewing the program without the changes proposed in the amendment, from Rep. Justin Amash Justin AmashOn The Trail: How Nancy Pelosi could improbably become president History is on Edward Snowden's side: Now it's time to give him a full pardon Trump says he's considering Snowden pardon MORE (R-Mich.).

“We were getting a minute-by-minute update. ‘Hey, there’s another one!’” said Rep. Tom Cole Thomas (Tom) Jeffrey ColeBottom line House approves .3 trillion spending package for 2021 Multiple lawmakers self-quarantine after exposure to Gohmert MORE (R-Okla.), reenacting the incident for reporters. “People were laughing about it.”

In the second tweet, Trump essentially said that he was in favor of the underlying bill but against the amendment. He also noted that he separately was taking action to change the rules for the “unmasking” of officials caught up on wiretaps.

Trump tweeted 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.”

The White House had already expected a fierce fight on the amendment before Trump put his own position briefly into question.

The amendment opposed by the administration had passed the House twice before, under former President Barack Obama Barack Hussein ObamaObama calls on Senate not to fill Ginsburg's vacancy until after election Senate Republicans face tough decision on replacing Ginsburg Cruz: Trump should nominate a Supreme Court justice next week MORE, and as late as Wednesday night officials were still making calls to try to sway uncertain members. White House chief of staff John Kelly John Francis KellyMORE was on the Hill Thursday to rally support.

In the end, the House voted to renew the program with a few small changes. Although some members had expected the tally to be close, the controversial amendment went down by 50 votes.

The vote was a pivotal moment in the battle over surveillance and privacy, dampening the hopes of those who wanted to limit the government’s powers.

Although Sens. Rand Paul Randal (Rand) Howard PaulSecond GOP senator to quarantine after exposure to coronavirus GOP senator to quarantine after coronavirus exposure The Hill's Morning Report - Sponsored by National Industries for the Blind - Trump seeks to flip 'Rage' narrative; Dems block COVID-19 bill MORE (R-Ky.) and Ron Wyden Ronald (Ron) Lee WydenGOP senator blocks Schumer resolution aimed at Biden probe as tensions run high Republican Senators raise concerns over Oracle-TikTok deal Hillicon Valley: TikTok, Oracle seek Trump's approval as clock winds down | Hackers arrested for allegedly defacing U.S. websites after death of Iranian general | 400K people register to vote on Snapchat MORE (D-Ore.) have vowed to filibuster the bill, the upper chamber is expected to swiftly take up and pass it. And despite the first tweet, Trump is expected to sign it.

House Speaker Paul Ryan Paul Davis RyanKenosha will be a good bellwether in 2020 At indoor rally, Pence says election runs through Wisconsin Juan Williams: Breaking down the debates MORE (R-Wis.) spoke to Trump after the initial tweet, but after the vote he batted down questions from reporters about whether Trump understood what the House was voting on and how his tweets sowed confusion on Capitol Hill.

“We speak on an almost daily basis. It’s well known that he has concerns about the domestic FISA law, but that’s not what we’re doing today. Today, we’re doing 702, which is a different part of that law,” Ryan said.

“He knows that, and he I think put out something that clarified that. And his administration's position has been the clear from day one, which is 702 is really important; it's got to be renewed.”

Supporters of the surveillance program have repeatedly complained that issues such as unmasking have been conflated with Section 702 of the Foreign Intelligence Surveillance Act, a law authorizing the government to spy on foreigners overseas.

Unmasking isn’t covered by Section 702, which allows the government to use any information they “incidentally” collect on Americans who are corresponding with legitimate foreign targets. Critics of the program say that investigators should have to seek a warrant before searching the database for American targets.

The two issues became politically linked last year when the president tweeted that the Obama administration had “wiretapped” his campaign at Trump Tower. Republicans have long speculated that former national security adviser Michael Flynn was caught up in 702 surveillance and inappropriately unmasked by Obama administration officials.

“There are FISA issues swirling around that have absolutely nothing to do with 702,” Rep. Mike Conaway Kenneth (Mike) Michael ConawayLive coverage: Democrats, Republicans seek to win PR battle in final House impeachment hearing Laughter erupts at hearing after Democrat fires back: Trump 'has 5 Pinocchios on a daily basis' Live coverage: Schiff closes with speech highlighting claims of Trump's corruption MORE (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.”

“I think the president’s instincts are great and I think he understands that all the evidence points to the fact that it sure looks like the FBI systematically went after him — so he’s concerned about all these possible infringements on the Fourth Amendment,” said Rep. Jim Jordan James (Jim) Daniel JordanHouse passes resolution condemning anti-Asian discrimination relating to coronavirus Republicans call for Judiciary hearing into unrest in cities run by Democrats Trump, GOP seek to rebut Democratic narrative on night one MORE (R-Ohio), a Freedom Caucus member who supported the amendment.

Melanie Zanona and Scott Wong contributed.