WASHINGTON (Reuters) - A U.S. House panel on Wednesday passed legislation seeking to overhaul some aspects of the National Security Agency’s warrantless internet surveillance program, overcoming criticism from civil liberties advocates that it did not include enough safeguards to protect Americans’ privacy.

An undated aerial handout photo shows the National Security Agency (NSA) headquarters building in Fort Meade, Maryland. NSA/Handout via REUTERS

The House Judiciary Committee voted 27-8 to approve the bill, which would partially restrict the U.S. government’s ability to review American data collected under the foreign intelligence program by requiring a warrant in some cases.

Lawmakers in both parties were sharply divided over whether the compromise proposal to amend what is known as Section 702 of the Foreign Intelligence Surveillance Act would enshrine sufficient privacy protections or possibly grant broader legal protections for the NSA’s surveillance regime.

“The ultimate goal here is to reauthorize a very important program with meaningful and responsible reforms,” Republican Bob Goodlatte, who chairs the committee, said. “If we do not protect this careful compromise, all sides of this debate risk losing.”

Passage of the House bill sets up a potential collision with two separate pieces of legislation advancing in the U.S. Senate, one favored by privacy advocates and one considered more acceptable to U.S. intelligence agencies.

Congress must renew Section 702 in some form before Dec. 31 or the program will expire.

U.S. intelligence officials consider Section 702 among the most vital of tools at their disposal to thwart threats to national security and American allies.

It allows the NSA to collect vast amounts of digital communications from foreign suspects living outside the United States.

But the program, classified details of which were exposed in 2013 by former NSA contractor Edward Snowden, incidentally gathers communications of Americans for a variety of technical reasons, including if they communicate with a foreign target living overseas. Those communications can then be subject to searches without a warrant, including by the Federal Bureau of Investigation.

The House bill, known as the USA Liberty Act, partially restricts the FBI’s ability to review American data collected under Section 702 by requiring the agency to obtain a warrant when seeking evidence of crime.

It does not mandate a warrant in other cases, such as requests for data related to counterterrorism or counter-espionage.

The committee rejected an amendment offered by Republican Representative Ted Poe and Democratic Representative Zoe Lofgren that would have generally required all searches of U.S. data collected through Section 702 to require a warrant. In 2014 and 2015 the full House of Representatives voted with strong bipartisan support to adopt such a measure, though it never became law.

“We have created a measure that has actually taken us backwards in terms of constitutional rights,” Lofgren said.