WASHINGTON — Defiant in one of her final appearances in office, Secretary of State Hillary Rodham Clinton told Congress on Wednesday that she accepts responsibility for security lapses in the deadly Sept. 11 attack on U.S. posts in Libya, but she also stressed that the assault was part of a broader war the United States faces against extremists in North Africa.

Although her voice cracked and she appeared close to tears when describing the deaths of Ambassador J. Christopher Stevens and three other Americans, Clinton overall seemed confident — even combative — when pressed on security lapses in the attacks in the eastern city of Benghazi.

The members’ questioning took on partisan tones, with Democrats blaming Congress for denying funds they say would’ve helped the State Department improve diplomatic security, and Republicans depicting an administration cover-up of high-level negligence in security measures. Clinton appeared first before the Senate Foreign Relations Committee and then before the House Foreign Affairs Committee.

Being hauled before Congress to answer for what an independent panel called “grossly inadequate” security procedures was hardly the ideal career capstone for a Washington fixture who vows to exit the political stage once her presumed successor, Sen. John Kerry, D-Mass., is confirmed. One Democrat openly lamented that Clinton’s final appearance before Congress was over a tragedy rather than to recap her diplomatic successes.

Unlimited Digital Access. $1 for 4 weeks.

“Nobody wants to sit where I am and have to think now about what coulda, shoulda, woulda happened,” Clinton told the Senate panel.

She tied the assault in Libya to last week’s hostage crisis in Algeria and the French-led military campaign against Islamist rebels in northern Mali.

Clinton portrayed the militant operation against the U.S. Consulate and nearby CIA annex in Benghazi as a direct consequence of the Arab Spring revolts, which toppled authoritarian rulers and gave operational space to long-suppressed radical forces. She said weapons that disappeared during the fall of former Libyan leader Moammar Gadhafi’s government undoubtedly had been smuggled to other countries, including for use in the Syrian uprising-turned-civil-war.

Clinton’s testimony contained hints about some of the obstacles U.S. diplomats face in North Africa’s democratic transitions: She said she had to “beg” the Tunisians to intervene to save the U.S. Embassy in Tunis from rioters; she said Libyans had the will to help secure U.S. diplomats but not the security capacity; she said U.S. officials had to get on the phone and tell the Egyptians to get their forces on the street when demonstrators appeared ready to breach the U.S. Embassy in Cairo.

“We are in a new reality,” Clinton told the Senate committee. “We are trying to make sense of changes that nobody had predicted but that we’re going to have to live with.”

A report by the independent Accountability Review Board, charged with investigating the deadly events in Libya, portrays a total system breakdown in the attacks, though the CIA wasn’t mentioned in the public version of the report.

Intelligence-agency reports failed to provide any “immediate, specific tactical warning” of the attacks, the panel found, adding, “known gaps existed in the intelligence community’s understanding of extremist militias in Libya and the potential threat they posed to U.S. interests.”

The consulate in Benghazi, according to the panel’s report, had an inadequate number of security agents and a lack of protective equipment, and was overseen by officials who failed to appreciate and craft a response to the city’s rapidly deteriorating security.

The Libyan militia that was assigned to protect U.S. convoys was on strike at the time of the attack, upset over wages and working hours.

While the report didn’t fill in the gaps on what the Obama administration knew about the attacks and when — one of the most controversial points in the government’s handling of the aftermath — the panel did find there was no anti-American demonstration preceding the attack, as senior officials once had insisted.

At least twice, Clinton’s voice cracked and she appeared close to tears when addressing the deaths of colleagues, but she also showed a combative streak, especially in firing back to suggestions that the department had failed to debrief evacuees to find out quickly whether the attack was the outgrowth of a spontaneous demonstration or a well-planned terrorist operation.

“The fact is, we had four dead Americans!” Clinton practically yelled to Sen. Ron Johnson, R-Wis., stressing that her first priority during the evacuation proceedings was treatment for the wounded, not debriefing evacuees.

“Was it because of a protest or because of guys out for a walk one night who decided they’d go kill some Americans?” she continued. “What difference at this point does it make? It is our job to figure out what happened and prevent it from ever happening again, senator.”

Republican lawmakers had demanded for months that Clinton explain in person the many missteps that an independent review panel found in her department’s handling of the Benghazi crisis.

Clinton’s appearance was delayed by a prolonged illness and a concussion, though some right-wing critics accused her of trying to wriggle out of her commitment to testify.

On Wednesday, Clinton reminded the committee that the review board had found that direct responsibility for the deficiencies highlighted during the Benghazi assault began at the level of assistant secretary and below.

Four State Department managers were placed on administrative leave as part of disciplinary actions related to the report’s findings; one of them resigned.