A bipartisan group of lawmakers have introduced a new bill that would, for the first time, restrict law enforcement's access to data collected by the National Security Agency.

It's the first legislative proposal to curb the use of a controversial foreign surveillance provision, but one that's likely to spark a fight between Congress and the Trump administration, which wants a clean and permanent reauthorization of the law.

A draft of the bill, seen by ZDNet, will largely renew the government's foreign surveillance provision, known as Section 702 of the Foreign Intelligence Surveillance Act (FISA), for six years.

Section 702 allows the NSA to gather intelligence on foreigners overseas by collecting data from chokepoints where fiber optic cables owned by telecom giants enter the US. The provision also authorizes the controversial PRISM program, which collects data from servers of internet giants.

But the collection also sweeps up large amounts of data on Americans, who are constitutionally protected from warrantless surveillance.

Both the Obama and Trump administrations have refused to disclose how many Americans are caught up in the dragnet.

The FBI and other civilian agencies, like the Drug Enforcement Administration, are also allowed to query the Section 702 database, which includes emails, messages, and phone metadata for criminal investigations, without needing a warrant.

But the group of lawmakers want that unfettered access by law enforcement to end.

The bill, drafted by House Judiciary Committee chairman Bob Goodlatte (R-VA) and vice-chairman John Conyers (D-MI), will require authorities to obtain a probable-cause warrant to view the information each time the Section 702 database returns a result on an American.

But the restriction will not apply to agencies that are conducting foreign intelligence, such as the NSA and the CIA, which carry out investigations in relation to counter-terrorism and espionage.

It's a change to the law that even former NSA director Michael Hayden is said to support. According to Marcy Wheeler, a national security blogger, Hayden said Tuesday that he would "support a reform to US person queries" to ensure Section 702 is reauthorized.

Several privacy and rights groups praised the effort, but warned it fell short of expectations.

"This legislation marks an important step forward for reining in the overly broad government surveillance revealed by Edward Snowden more than four years ago," said Nuala O'Connor, president of the Center for Democracy & Technology.

"But, the legislation must do more to protect the rights of both US and global citizens," she added.

"However, the bill fails to close the 'backdoor search loophole'," she said, referring to incidentally collected data," which leaves Americans exposed to surveillance that should be permitted only with a court order based on a showing of probable cause."

The ACLU and the Open Tech Institute also released statements calling for additional protections to be added to the final bill.

"It also fails to ensure that people are wiretapped only if there is a good reason for listening in," she added.

The bill, if passed, will also extend whistleblower protections to contractors who work for private sector companies, like Booz Allen Hamilton, while also increasing penalties for those who mishandle classified material.

The draft bill comes just two months before the Section 702 provision is set to sunset at the end of the year.

The surveillance powers, introduced in 2008 following the Bush administration's use of warrantless domestic wiretapping, were brought to wider attention following the mass disclosure of classified programs by whistleblower Edward Snowden in 2013. Although one of the phone metadata collection programs was curtailed when the Freedom Act was ratified in 2015, lawmakers have left the foreign intelligence statutes alone until this year.

Lawmakers have spent the past few months holding several hearings on Section 702 in an effort to understand the provision better.

According to recent research, there have been at least 200 violations of the Section 702 provision in the past decade.

Several other bills are expected before the end of the year.