Senate leaders are planning to send to the president's desk next week a bill to reauthorize the government's authority to conduct foreign surveillance on U.S. soil, despite opposition from privacy advocates and mixed messages from President Trump himself, who questioned his administration's support for the program Thursday morning.

The Senate voted 69 to 26 Thursday to start debate on the bill, which would extend for six years the National Security Agency's ability to collect from U.S. companies the emails and other communications of foreign targets located outside the United States. The vote came hours after the House voted 256 to 164 to approve the legislation and is a sign that lawmakers intend to move swiftly to pass the measure before the program's statutory authority expires Jan. 19.

The intelligence community considers the program — known as Section 702, named for its place within the Foreign Intelligence Surveillance Amendments Act that established it in 2008 — to be its key national security surveillance tool. But privacy advocates oppose the law, arguing that there are not enough limits to federal law enforcement agencies' ability to scour the communications of Americans in touch with foreign targets.

Sen. Rand Paul (R-Ky.) said Thursday that he intended to do "everything in my power, including filibuster," to impede the bill next week, although that is unlikely to block its passage. A House effort to amend the bill and require the federal government to obtain warrants before searching for Americans' information failed Thursday by a vote of 233 to 183.

Instead, the greater threat to the fate of Section 702 came from the president, in a pair of contradictory and seemingly misinformed tweets posted after watching a segment about the bill on Fox News Channel.

" 'House votes on controversial FISA ACT today,' " Trump wrote, citing a Fox News headline. "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?"

The dossier, which was compiled by a British ex-spy, alleges Trump's campaign had ties to Russia. It is unclear what the president thought it had to do with reauthorizing the surveillance program, but Trump has repeatedly denounced it in recent days.

Trump attempted to walk back his tweet about 90 minutes later, urging lawmakers in a second tweet to reauthorize the program. But top Democrats seized on the confusion, calling on Republican leaders to withdraw the bill from consideration "in light of the irresponsible and inherently contradictory messages coming out of the White House today," Rep. Adam B. Schiff (Calif.), the top Democrat on the Intelligence Committee, said on the House floor.

Republicans seemed undeterred by Democrats' demands. But behind the scenes, the president's mixed messages rattled the House GOP, whose members gathered for a regular conference meeting shortly after Trump sent his initial tweet.

The president's chief of staff, John F. Kelly, scrambled to Capitol Hill, while panicked aides alerted Trump to the firestorm his tweets had caused. The president was seemingly misinformed about the nature of the vote and the substance of the bill, people said.

Eventually, Trump called House Speaker Paul D. Ryan (R-Wis.), and they spoke for a half-hour. After the House vote, Ryan insisted to reporters that Trump "knows what 702 is" and simply "has concerns on FISA."

When Trump issued his second tweet, House Majority Leader Kevin McCarthy (R-Calif.) handed his phone to Intelligence Committee Chairman Devin Nunes (R-Calif.), the bill's sponsor. Nunes read the tweet aloud to the GOP conference, calming lawmakers' nerves.

But top Democrats on the House and Senate intelligence committees already had seized on the president's first tweet, excoriating it as "irresponsible" and "untrue."

"FISA is something the President should have known about long before he turned on Fox this morning," Sen. Mark R. Warner (Va.), the top Democrat on the Senate Intelligence Committee, tweeted after Trump's post.

In his second tweet, Trump seemed to backtrack, pushing for the act to be renewed.

"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!" Trump wrote on Twitter.

It is unclear how Trump "personally directed the fix to the unmasking process since taking office." Nunes stripped major changes to unmasking procedures from the measure before presenting it for a vote by the full House. 

Senior government officials can ask spy agencies to "unmask" the names of Americans or U.S. organizations if they think it will help them better understand the underlying intelligence. Trump and Nunes have accused the Obama administration of improperly revealing the identities of members of the president's transition team.

Republicans and Democrats have pushed back against linking the FISA program to the controversy over unmasking. On Thursday, White House cyber coordinator Rob Joyce said there have "been no cases of 702 used improperly for political purposes."

Before Trump's tweets, it was the opposition of privacy advocates that presented the chief obstacle to renewing Section 702. They had rallied around an alternative measure from Rep. Justin Amash (R-Mich.) that would have required law enforcement agencies to obtain warrants before being able to sift through the NSA's records database. The underlying bill requires only that the government seek a court order when it wants to use information about Americans in criminal cases.

"The government will use this bill to continue warrantless intrusions into Americans' private emails, text messages, and other communications. No president should have this power," American Civil Liberties Union policy counsel Neema Singh Guliani said in a statement after the House's vote, calling on the Senate to "reject this bill."

Trump's tweets came shortly after a "Fox and Friends" segment that highlighted the FISA program, calling it "controversial." His first tweet seemed to side more with civil liberties groups and House Democrats who have pushed for less-invasive measures.

Trump's administration has been consistent in pushing for the FISA program to be reauthorized, with FBI Director Christopher A. Wray calling it a valuable tool to fight terrorism. The White House has issued statements this week and asked lawmakers to reauthorize it, even urging members to vote against the Amash amendment Wednesday night.

Ellen Nakashima and Erica Werner contributed to this report.