Civil liberties groups have been emboldened by a recent court decision declaring NSA spying illegal, and some are seeking even more ambitious reforms.

The legislation is opposed by allies of the NSA, who would prefer to reauthorize current law, which expires on June 1.

The House of Representatives passed the USA FREEDOM Act in a lopsided 338-88 vote. The legislation is designed to curtail surveillance by the National Security Agency.

Debate over the legislation has focused on a controversial program that scoops up records of every American's phone calls. The existence of the program was revealed by a 2013 leak from whistleblower Ed Snowden, and it's been in operation for about a decade.

The government says the program is authorized by Section 215 of the Patriot Act, which was passed in 2001 in the wake of the 9/11 terrorist attacks. Section 215 allows the government to seek information that is "relevant to an authorized investigation." The Obama administration has argued that a database of every phone call in the United States qualifies because it provides a wealth of information that helps the government conduct terrorism investigations.

But critics disagree. For example, the author of the Patriot Act, Rep. James Sensenbrenner (R-WI), suggested in 2013 that the government's interpretation of the law makes "a mockery of the legal standard."

Either way, Section 215 is due to expire at the end of the month, so Congress faces pressure to either reauthorize it or replace it with more restrictive language.

An appeals court recently said the program was illegal

Civil liberties groups have challenged the NSA's actions in court, and last week the Second Circuit Court of Appeals gave them a major win. While Section 215 of the Patriot Act gives the government broad latitude, the court held, it's not unlimited. And the NSA's program, which scoops up every American's phone records, doesn't pass muster.

The ruling has strengthened the hand of NSA critics by ratifying their view that the NSA had flouted the law. "The dragnet collection of Americans’ phone records is unnecessary and ineffective," said Sen. Patrick Leahy (D-VT) and Sen. Mike Lee (R-UT) after the ruling. "Congress should not reauthorize a bulk collection program that the court has found to violate the law."

After the ruling, one major civil liberties group, the Electronic Frontier Foundation, even decided to oppose the legislation the House passed Wednesday because it didn't go far enough to rein in the NSA. The group says it has supported previous iterations of the bill — "more reluctantly each time" as it has been watered down to satisfy critics. But after the court ruled the program was illegal, EFF "decided that Congress can significantly strengthen the bill."

The USA FREEDOM Act is opposed by NSA hard-liners such as Senate Majority Leader Mitch McConnell (R-KY), who would prefer to reauthorize Section 215 in its current form. But that position was weakened by last week's court ruling, because even if Congress reauthorizes the provision, the courts might still force the government to shut down its phone records program.

Correction: I mistyped the number of "yes" votes, 338, as 388.