One of the most important surveillance tools used by intelligence officials in the fight against terrorism is headed for renewal before it expires at the end of the year.

But lawmakers in both parties pledge to make changes to Section 702 of the Foreign Intelligence Surveillance Act, or FISA, they say are needed to protect privacy and prevent it from being abused for political purposes.

The House Judiciary Committee and Senate Intelligence Committee each took action on the provision in the past two weeks, adding new layers of protection aimed at shielding American citizens caught up in anti-terror surveillance and countering the pattern of unmasking of eavesdropped White House officials that has been damaging to the Trump administration.

The House panel last week voted to require intelligence officials to request a warrant from the FISA court before looking through emails and phone records of American citizens.

The panel also added a new requirement in response to a pattern of unmasking of Trump administration officials by people within the federal government who then leaked information to the press.

The leaking has angered many Republican lawmakers, in particular House Intelligence Committee Chairman Devin Nunes, R-Calif., who has said the abuse of the spying tool may make it harder to win GOP support for renewing it.

The Judiciary Committee has added a provision that would require intelligence agencies “to keep records of queries” and would require the government to “officially retain unmasking requests” so Congress can monitor them, among other related changes.

The measure passed the Judiciary Committee by a vote of 27-8.

Panel Chairman Bob Goodlatte, R-Va., called the bill “the best legislative solution to preserve this important national security tool while also providing for much needed reforms.”

The Senate Intelligence Committee, meanwhile, advanced its own changes to the FISA tool.

The Senate proposal would not require a warrant to search phone and email records of citizens, but would require the FBI to quickly seek permission from the special FISA court if wants to use information obtained from Americans.

Like the House version, the Senate bill stiffens penalties for leaking classified information.

The renewal of the 702 spying provision may hit its biggest hurdle in the House, where it must receive the approval of the Intelligence Committee.

Nunes, who has ordered an investigation into the unmasking and whether it was politically motivated, has warned it may make it harder for GOP lawmakers to support renewing the surveillance provision, although he acknowledged it is a critical anti-terror tool.

“We are working with the Senate to try to figure out a pathway forward,” Nunes told the Washington Examiner.

The top Democrat on the panel, Rep. Adam Schiff, D-Calif., told the Washington Examiner he wants to add more provisions to enhance privacy protections, but isn’t interested in addressing the unmasking issue in the legislation.

Schiff leads the Democratic side of the Intelligence Committee as it investigates whether Russia influenced the 2016 elections or colluded with the Trump campaign.

He’s often disagreed with Nunes over the unmasking probe, which likely involves former Obama administration officials.

“There are some additions we’d like to make,” Schiff said of the spying measure. “I’m concerned we not politicize the bill by putting in unrelated items that are designed to foster a political narrative. That could become an impediment.”