WASHINGTON -- Former CIA Director David Petraeus told lawmakers Friday that classified intelligence showed the deadly raid on the U.S. Consulate in Libya was a terrorist attack, but that the administration withheld the suspected role of specific al-Qaida affiliates.

The spy chief, who resigned a week ago over an extramarital affair, said references to terrorist groups suspected of carrying out the violence that killed the U.S. ambassador were removed from the public explanation of what caused the attack so the groups would not know that the U.S. intelligence community was on their trail.

Petraeus also said it initially was unclear whether militants infiltrated an anti-U.S. protest to cover their attack.

The retired top general addressed the House and Senate intelligence committees in closed-door hearings as questions persist over what the Obama administration knew just after the Sept. 11 attacks and why its public description did not match intelligence agencies' assessments.

The issue has threatened to affect the search for a new U.S. secretary of state once Hillary Rodham Clinton steps down. Clinton will testify next month on the attack.

Lawmakers said Petraeus testified that the CIA's draft talking points written in response to the Benghazi assault referred to it as a terrorist attack but that the reference was removed from the final version. He wasn't sure which federal agency deleted it.

Democrats said Petraeus made it clear the change was not made for political reasons during President Barack Obama's re-election campaign.

"The general was adamant there was no politicization of the process, no White House interference or political agenda," said Rep. Adam Schiff. "He completely debunked that idea."

But Republicans remained critical of the administration's handling of the case. Sen. Marco Rubio said Petraeus' testimony showed that "clearly the security measures were inadequate despite an overwhelming and growing amount of information that showed the area in Benghazi was dangerous, particularly on the night of Sept. 11."

Petraeus told lawmakers that security at the consulate was so lax that protesters literally walked in and set fire to the facility, according to a congressional official who attended the briefing, leading to Ambassador Chris Stevens' death from smoke inhalation. Petraeus said security at the CIA annex nearby was much better, but the attackers had armaments to get in.

Petraeus, who had a long and distinguished military career as the top U.S. commander in Iraq and Afghanistan, was making his first Capitol Hill testimony since resigning a week ago over an affair with his biographer, Paula Broadwell. Lawmakers said he did not discuss that scandal except to express regret about the circumstances of his departure and say that the Benghazi attack had nothing to do with his decision to resign.

Petraeus testified that the CIA draft written in response to the attack referred to militant groups Ansar al-Shariah and al-Qaida in the Islamic Maghreb, but those names were replaced with the word "extremist" in the final draft, according to a congressional staffer. Petraeus said he allowed other agencies to alter the talking points as they saw fit without asking for final review, to get them out quickly, the staffer said.

The congressional officials weren't authorized to discuss the hearing publicly and described Petraeus' testimony on condition of anonymity.

Sen. Mark Udall said Petraeus explained that the CIA's draft points were sent to other intelligence agencies and to some federal agencies for review. Udall said Petraeus told lawmakers the final document was put in front of all the senior agency leaders, including Petraeus, and everyone signed off on it.

"The extremist description was put in because, in an unclassified document, you want to be careful who you identify as being involved," Udall said.

The edited version was used by U.N. Ambassador Susan Rice five days after the attack, when the White House sent her out for a series of television interviews. Republicans have criticized Rice for saying it appeared the attack was sparked by a spontaneous protest over an anti-Muslim video produced in the U.S.

Schiff said Petraeus said Rice's comments "reflected the best intelligence at the time that could be released publicly."

"The fact is, the reference to al-Qaida was taken out somewhere along the line by someone outside the intelligence community," Rep. Peter King said. "We need to find out who did it and why."

King said Petraeus had briefed the House committee on Sept. 14, and he did not recall Petraeus being so positive at that time that it was a terrorist attack. "He thought all along that he made it clear there was terrorist involvement," King said. "That was not my recollection."

Lawmakers have spent hours interviewing top intelligence and national security officials, trying to determine what intelligence agencies knew before, during and after the Libya attack. They viewed security video from the consulate and surveillance footage take by an unarmed CIA Predator drone that showed events in real time.

The congressional staffer told the AP that the composite video shown to lawmakers to illustrate the chronology of the attack included the cellphone footage that has been on YouTube showing the ambassador being carried out by people who looked like they were trying to rescue him.