It’s the NSA’s most cherished mass-surveillance law, albeit one civil libertarians consider dubiously constitutional. And the chairman of the House Intelligence Committee helped jeopardize its renewal, The Daily Beast has learned—by resurrecting a pseudo-scandal of his own invention.

In recent months, congressional negotiators have been working on a bill codifying an umbrella of mass-surveillance activities known as Section 702 of the Foreign Intelligence Surveillance Act. The authorization for those activities is due to expire in a matter of days.

But Chairman Devin Nunes threw a monkey wrench into the process, by initially pushing to include in the bill an unrelated a provision on so-called unmasking, the process that intelligence agencies use to reveal the names of U.S. persons who may be involved in crimes like spying.

(Last year, as the Trump-Russia probe began to heat up, Nunes led a sideshow investigation into allegations that Obama administration officials improperly “unmasked” the names of Trump campaign staffers.)

Nunes’ effort played a role—though a minor one—in slowing down negotiations. It was a major departure from politics as usual for the chairman of the powerful House Intelligence Committee.

Nunes was ultimately forced to strip the provision, which was far from the only hurdle the Section 702 reauthorization had to clear. What distinguished it, multiple Hill and intelligence sources told The Daily Beast, was that it was the only unforced error in the process—the result of Nunes’ effort to resurrect a controversy members of his own party have dismissed.

Reauthorizing the program is the top legislative priority of the Justice Department, an official there told The Daily Beast. Attorney General Jeff Sessions directed Associate Attorney General Rachel Brand to make the reauthorization fight her top priority.

Brand’s position in the department doesn’t typically involve national-security matters. But her time on the Privacy and Civil Liberties Oversight Board has made her one of the department’s top advocates on national-security law. She met with members of the House and Senate, and conducted a media blitz—she appeared on Hugh Hewitt’s MSNBC show and Dana Perino’s Fox News show, sat for an interview with WTOP’s national-security podcast, and wrote an op-ed for The Washington Post.

The House will introduce a legislation to preserve Section 702 on Tuesday—just 10 days before its deadline.

Section 702 would have expired on Dec. 31, but Congress voted to extend that deadline to Jan. 19. It’s an issue that slices through partisan lines, pitting congressional progressives and Tea Party civil libertarians against members who defend the positions of the national-security community. Typically, the Republicans and Democrats who helm the House and Senate intelligence committees are vocal advocates for the program.

“ Top intelligence officials presented a consistent message on Section 702: that it was a crucial authority that the Hill needed to preserve. ”

But this time around, the feud between President Donald Trump and the security agencies—which he calls “the Deep State”—scrambled politics-as-usual.

As the House committee put together its bill to reauthorize Section 702 in November, Nunes inserted a provision on “unmasking.”

While Nunes was momentarily able to turn the relatively routine process of unmasking into a minor scandal, his Republican counterpart on the Senate Intelligence Committee, Richard Burr, downplayed Nunes’ concerns to CNN.

“The unmasking thing was all created by Devin Nunes, and I’ll wait to go through our full evaluation to see if there was anything improper that happened,” Burr told CNN in July.

Despite that, Nunes pushed hard for changes in the intelligence community’s unmasking procedures. That effort irked even his Republican colleagues on the intelligence committee. Getting their version of the reauthorization through the House was hard enough: Civil libertarians have embraced a rival reauthorization bill from the House Judiciary Committee and have condemned the intelligence committee’s version, which is now the basis for Tuesday’s bill.

In the meantime, on Dec. 8, Reuters reported that Director of National Intelligence Dan Coats moved unilaterally to change unmasking procedures.

Section 702 is a shorthand name for a sweeping set of surveillance authorities, including the NSA’s warrantless mass-collection of international communications involving Americans. Since its passage in 2008, and particularly since Edward Snowden’s 2013 surveillance revelations shed significant light on its scope, critics have contended the measure is an unconstitutional end-run around the Fourth Amendment’s protections against unreasonable searches and seizures.

Its vast collection of communications and associated data from major tech firms, known as PRISM, and its siphoning of the same in transit across the internet, known as Upstream, all occur without judicial review, let alone approval, of the National Security Agency’s targets. Instead, judges on a secret court annually review collection procedures—or, at least, how those collection procedures are supposed to work. On repeated occasions, the FISA Court has found that the NSA has vacuumed up vastly more than it let on. Most recently, in April, the agency admitted violating court-instituted boundaries on collecting communications that merely referenced or discussed surveillance targets under Section 702.

National-security leaders, meanwhile, contend it’s a vital intelligence-gathering tool.

Trump’s feud with the Deep State turned Nunes from a reliable Hill ally of the intelligence community to one of its most vociferous critics. By March 2017, after a deluge of leaks presumed to come from the security agencies, Nunes publicly threatened Section 702. Its reauthorization was “problematic” should anti-Trump leaks continue, he told reporters.

Later that month, NSA Director Mike Rogers and then-FBI Director James Comey heard similar notes from other senior Republicans. They expressed outrage that Mike Flynn, Trump’s first national security adviser, had been outed in the press as communicating with Russian ambassador Sergey Kislyak and warned that it showed passage-threatening abuses with Section 702.

“It could be you,” Rep. Trey Gowdy told Rogers and Comey. “It could be me.”

And it was conspicuously political. The surveillance intercept of the Flynn-Kislyak conversations from December 2016 did not occur under Section 702, since it was specific collection on an unambiguous agent of a foreign power—the Russian ambassador—on American soil. Nor had Nunes, Gowdy, or other intelligence-committee Republicans expressed similar privacy concerns after Snowden exposed the expansive reach of Section 702.

Even as the White House continued to fume at the intelligence agencies for what Trump called their “witch hunt” into his Russia ties, his administration’s top intelligence officials presented a consistent message on Section 702: that it was a crucial authority that the Hill needed to preserve, without substantial modification—or delay.

As crunch time approached during the fall, the House Intelligence Committee quietly reverted to type. The digital-rights group Access scored its Section 702 bill the lowest in its analysis of the competing 702 measures for protecting privacy and promoting transparency.

Yet the committee lost time throughout that period, in part because of Nunes’ insistence on including the unmasking provision. Republicans on the panel, sources said, went along, but mostly to humor the chairman. It struck some of them, as well as the Democrats, as an irrelevant distraction from a major legislative priority.

Nevertheless, Nunes persisted. But delays mounted, all while the GOP authors of the judiciary committee alternative, the USA Liberty Act, pressed to bring their alternative to the floor. By Dec. 20, as the 2017 legislative calendar ran down, Nunes conceded his bill was dead. A stopgap measure in the Continuing Resolution punted Section 702 reconsideration to Jan. 19.

Now, absent the unmasking provision, the House Intelligence Committee may still get its way. Its bill will form the template for the Section 702 reauthorization measure that returns to the House on Tuesday.

Updated to correct the name of the Judiciary Committee bill to the USA Liberty Act.