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 to avoid tipping off the terrorist groups.

The recently resigned spy chief explained that references to terrorist groups suspected of carrying out the violence were removed from the public explanation of what caused the attack so as not to tip off the groups that the U.S. intelligence community was on their trail, according to lawmakers who attended the private briefings.

Petraeus also said it initially was unclear whether militants infiltrated a demonstration to cover their attack.

The retired four-star general addressed the House and Senate intelligence committees in back-to-back, closed-door hearings as questions persist over what the Obama administration knew in the immediate aftermath of the Sept. 11 attacks and why their public description did not match intelligence agencies' assessments.

After the hearings, lawmakers who questioned Petraeus said he testified that the CIA's draft talking points written in response to the assault on the diplomat post in Benghazi that killed four Americans referred to it as a terrorist attack. But Petraeus told the lawmakers that reference was removed from the final version, although he wasn't sure which federal agency deleted it.

Democrats said Petraeus made it clear the change was not done 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, D-Calif. "He completely debunked that idea."

But Republicans remain critical of the administration's handling of the case. Sen. Marco Rubio, R-Fla., 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 was much better, but the attackers had armaments to get in.

Petraeus, who had a long and distinguished military career, was making his first Capitol Hill testimony since resigning last week in disgrace over an extramarital 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 Benghazi had nothing to do with his decision to resign.

Petraeus testified that the CIA draft written in response to the raid 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. The staffer said Petraeus testified that he allowed other agencies to alter the talking points as they saw fit without asking for final review to get them out quickly.

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

Sen. Mark Udall, D-Colo., 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 them the final document was put in front of all the senior agency leaders, including Petraeus, and everyone signed off on it.

"The assessment that was publicly shared in unclassified talking points went through a process of editing," Udall said. "The extremist description was put in because in an unclassified document you want to be careful who you identify as being involved."

Rep. Peter King, R-N.Y., said it remained unclear how the final talking points developed. 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.

"The fact is, the reference to al-Qaida was taken out somewhere along the line by someone outside the intelligence community," 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."

After two hours with Petraeus, the Democratic chairman of the Senate's intelligence committee and the panel's top Republican sparred over Rice's televised comments.

Chairman Dianne Feinstein, of California, said Rice used unclassified talking points prepared by the intelligence community and made available to Rice by the House's intelligence panel.

"The key is they were unclassified talking points at a very early stage," Feinstein said. "I don't think she should have been pilloried for this."

She recalled the faulty intelligence of the George W. Bush administration, when it justified the invasion of Iraq by concluding that country had weapons of mass destruction.

"A lot of people were killed based on bad intelligence," she said. Feinstein added that mistakes were made in the initial intelligence on Benghazi but said "I don't think that's fair game" to blame Rice — who could be nominated as secretary of state. "To say she is unqualified to be secretary of state I think is a mistake."

Top Republican Sen. Saxby Chambliss, of Georgia, said Rice went beyond the talking points.

"She even mentioned that under the leadership of Barack Obama we had decimated al-Qaida. She knew at that point in time that al-Qaida was responsible in part or in whole for the death of Ambassador Stevens," Chambliss said.

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

"There was an interagency process to draft it, not a political process," Schiff said. "They came up with the best assessment without compromising classified information or source or methods. So changes were made to protect classified information."

Sen. Kent Conrad, D-N.D., said it's clear that Rice "used the unclassified talking points that the entire intelligence community signed off on, so she did completely the appropriate thing." He said the changes made to the draft accounts for the discrepancies with some of the reports that were made public showing that the intelligence community knew it was a terrorist attack all along.

Lawmakers spent hours Thursday interviewing top intelligence and national security officials, trying to determine what intelligence agencies knew before, during and after the 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 also included the cellphone footage that has been on YouTube showing Stevens being carried out by people who looked like they were trying to rescue him.

--The Associated Press