WASHINGTON — The House voted Thursday to renew a controversial surveillance program that targets foreign terrorists but also sweeps up emails, texts and other electronic communication from an unknown number of Americans.

The Senate is expected to vote on the bill next week, before the program expires on Jan. 19. The president, after issuing some confusing and contradictory tweets about the law, supports the House action, according to the White House.

Here's a look at what the surveillance law does and how it could affect you:

Which surveillance program are we talking about here?

The program is known as Section 702 of the Foreign Surveillance Intelligence Act. The Section 702 program was originally approved by Congress in 2008 to increase the government's ability to track and thwart foreign terrorists in the wake of the 9/11 attacks.

What is the Section 702 program designed to do?

The law gives U.S. intelligence agencies the power to spy on the electronic communications and phone calls of foreigners residing outside the United States to try to gather information about any terrorist plots or activities.

So what's wrong with that?

Almost no one has any objection to the program's stated goal. The problem, according to privacy advocates and civil liberties groups, is that the emails, photos, texts and other electronic communications of U.S. citizens and legal U.S. residents are also collected while our government is spying on foreigners.

That could happen if a citizen is communicating with a foreigner who is under surveillance, even if that foreigner isn't suspected of being a terrorist. It also could happen if two Americans are communicating with one another and mention the name of a foreigner who is under surveillance.

The reason that critics of the law are so upset is that the program essentially gives law enforcement agencies a "backdoor" to search Americans' data without having to get a warrant.

Under the Fourth Amendment to the U.S. Constitution, Americans are protected from unreasonable searches and seizures. Law enforcement officials typically have to go to court and ask a judge to issue a search warrant. They must show probable cause to believe that evidence of a crime will be found.

Isn't it impossible for U.S. intelligence agencies to spy on foreigners without scooping up some American data in the process?

Yes, it's unrealistic to think that they won't see any messages from Americans who are communicating with foreign nationals. The problem, critics say, is not simply that the information is collected but what is done with it after it is gathered.

The information becomes part of a database that the FBI or other federal law enforcement agencies could then search to find evidence that Americans are engaged in domestic crimes that have nothing to do with terrorism. For example, it could be used to find evidence that an American citizen isn't paying his or her taxes or has committed a minor drug offense, according to the ACLU and other civil liberties groups.

How do I know if my emails or texts have been collected or searched under this law?

There's no way to know for sure unless you are charged with a crime and prosecutors disclose that they have evidence obtained through Section 702. Congress members have repeatedly asked intelligence agencies to reveal how many Americans have had their data collected under the program, but the agencies have never provided an answer.

What did Congress do Thursday?

The House voted 256-164 to renew the existing surveillance law for another six years —with some tweaks.

The revised law would restrict the use of data collected under Section 702 in some criminal prosecutions of U.S. citizens. It also would temporarily stop federal agents from collecting communications that mention a surveillance target — but aren't to or from that target — until the Intelligence Community presents Congress with new procedures for gathering that information.

The House defeated an alternative bill by Reps. Justin Amash, R-Mich., and Zoe Lofgren, D-Calif., that would have required federal agents to get warrants before searching through Americans' data.

Supporters of that bill said it provided much stronger privacy and civil liberties protections for Americans, but opponents said it could hamstring investigators from getting the information they need to foil terrorists.

Where does President Trump stand?

Well, the president created quite a bit of confusion over his position with some contradictory tweets on Thursday morning.

Trump first took the remarkable step of tweeting his apparent opposition to the surveillance law despite the fact that prior presidents, the intelligence community and even his own administration have fought to maintain the program. Trump suggested that the Obama administration used this law to spy on him and his campaign.

“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 later tweeted what seemed to be a clarification of his position in favor of renewing the law, saying that "today’s vote is about foreign surveillance of foreign bad guys on foreign land. We need it! Get smart!"

The official White House position, which was announced in a statement issued Wednesday night, was in favor of the bill the House passed and against the Amash-Lofgren alternative.

What happens next?

The Senate still must vote on the bill before the program expires on Jan. 19. Sen. Rand Paul, R-Ky., has vowed to filibuster the legislation approved by the House. But the Senate is ultimately expected to pass the bill and send it to Trump, who will likely sign it.

Congress is unlikely to let the program just lapse, because the U.S. Intelligence Community has warned that doing so could prevent them from stopping a terrorist attack. They say the law has already thwarted several terrorist plots against the U.S., including a planned attack on the New York City subway system.