The National Security Agency's massive data collection program has prompted lawsuits, internal reviews and a fierce congressional debate over whether to scrap it.

But Director of National Intelligence James Clapper apparently forgot the program even existed during a key hearing two years ago.

Robert Litt, the DNI's general counsel, revealed the major memory lapse during a panel discussion Friday hosted by the Advisory Committee on Transparency. He was offering an explanation as to why, in a now-infamous exchange several months before Ed Snowden-leaked materials surfaced on the NSA program, Clapper told a Senate committee that the government does not "wittingly" sweep up information on millions of Americans.

He wasn't lying, Litt said. Rather, "It was perfectly clear that he had absolutely forgotten the existence of the 215 program."

The claim may be startling for the lawmakers, civil liberties advocates and transparency groups who have debated the program intensely since it was revealed in a series of media reports in mid-2013.

The 215 program allows the NSA to collect so-called "metadata" on phone calls -- including the number called and the date and time of the call -- then stores it in a database that it queries using phone numbers associated with terrorists overseas. Officials say they don't use the information for any other purpose, and that the legal powers that enable the program are essential to the hunt for terrorists. Opponents say the seizure and search of telephone company records violates Americans' expectations of privacy under the Fourth Amendment.

Clapper's early 2013 testimony created a congressional controversy after the Snowden revelations showed the NSA was gathering data on Americans.

At the hearing, Oregon Democratic Sen. Ron Wyden asked Clapper whether the NSA "collects any type of data at all" on millions of Americans.

Clapper told Wyden: "No sir, it does not." Asked for clarification, he said "not wittingly."

Clapper later apologized, sending a letter to the Senate Intelligence Committee admitting his answer was "clearly erroneous." He said that he "simply didn't think" of Section 215 of the Patriot Act, and was thinking of a different provision of a different law.

Litt offered more details on Friday of what happened behind the scenes of that hearing. He said they were only notified the day before that Wyden would ask that question.

"The DNI did not get a chance to review it," Litt said. "He was hit unaware by the question."

Litt, whose comments were first reported in The Hill, said it was not "an untruth or a falsehood" on Clapper's part. "This was just a mistake on his part. We all make mistakes," he said.

He said he realized Clapper forgot after personally telling him he had been wrong. He said Clapper was thinking about a separate program used to sweep up Internet information on foreigners. Litt said he should have corrected the mistake right away.

Litt's explanation comes as the courts and Congress debate the program anew.

A federal appeals court ruled Thursday that the bulk collection of Americans' phone records is illegal. The court all but pleaded for Congress to sharpen the boundaries between security and privacy rights.

Meanwhile, lawmakers are weighing the renewal of the USA Patriot Act, including data collection provisions. The House is slated to vote next week on a bill to reauthorize the law while also ending the government's dragnet collection of records.

But Senate leaders, including Majority Leader Mitch McConnell, R-Ky., and Sen. Richard Burr, R-N.C., the chairman of the Intelligence Committee, have spoken forcefully for a competing measure to reauthorize the law as-is.

Across Congress, the political divisions cut along complex lines. Libertarian-leaning Republicans like Sen. Ted. Cruz and Sen. Rand Paul are aligned with many liberal Democrats, insisting that a secret intelligence agency should not be storing the records of every American phone call. But other Democrats and Republicans say the program is needed now more than ever given the Islamic State group's determination to inspire terrorist attacks on American soil.

The Associated Press contributed to this report.