Correction: An earlier version of this article incorrectly described Sen. Lindsey O. Graham as representing North Carolina. He represents South Carolina.

During Sen. Chuck Hagel’s confirmation hearing for defense secretary, Sen. John McCain (R-Arizona) asked Hagel if he felt he was correct when he voiced opposition against the 2007 troop surge in Iraq. (The Washington Post)

Chuck Hagel, President Obama’s nominee as defense secretary, confronted withering criticism during a marathon confirmation hearing Thursday, but administration officials said they felt confident that the Republican-led attacks did not derail his bid to lead the Pentagon.

Lawmakers from both parties spent roughly eight hours grilling Hagel about remarks he has made at various points of his career and the votes he had cast in the Senate. The nominee at times struggled as he sought to explain his past positions, in some cases distancing himself from them. He nonetheless offered a full-throated endorsement of the United States’ alliance with Israel, insisted that he has never advocated for unilateral nuclear disarmament and called Iran an existential threat.

An administration official said the combative nature of the hearing did not come as a surprise for a nominee who has faced more sustained and personal opposition than any of Obama’s Cabinet picks.

“There’s no indication that this is peeling off any support that was there before today,” said the official, who spoke on the condition of anonymity to discuss the administration’s internal assessment of the hearing.

The ranking Republican on the Armed Services Committee set the tone for the confirmation hearing for Hagel, a former Republican senator from Nebraska with a reputation for bluntness but also nuanced foreign policy views.

Sen. Lindsey Graham (R-South Carolina) asked Sen. Chuck Hagel to name “one dumb thing” the Senate has done in regards to U.S. relations with Israel. (The Washington Post)

“Why do you think that the Iranian Foreign Ministry so strongly supports your nomination to be the secretary of defense?” Sen. James M. Inhofe (R-Okla.) asked Hagel, in an apparent reference to an Iranian news agency report conveying hope from the Islamic republic that Hagel’s confirmation would bring “practical changes” in U.S. policy.

Hagel appeared defensive, frustrated and lethargic during much of the hearing. But none of the zingers or missteps appeared serious enough to sway a significant number of senators to vote across party lines. Democrats outnumber Republicans on the committee 14 to 12, and administration officials and analysts said the vote would probably fall along party lines.

“None of the votes that probably would have been for him have shifted,” said Steve Clemons, a fellow at the New America Foundation who supports Hagel’s nomination. But he expressed surprise by the lack of charisma the seasoned politician displayed on the witness chair. “Hagel, who can be hilarious, didn’t show much of that today,” Clemons lamented.

Hagel’s nomination has triggered sustained criticism since his name was first suggested for the job in December. Previous remarks and votes on issues ranging from sanctions against Iran to the propriety of having an openly gay ambassador became fodder for a barrage of ads and an intense lobbying campaign that has sought to doom his nomination.

During his opening statement, Hagel defended his record, saying he always acted with integrity but acknowledging that it was not devoid of “mistakes.” If he is confirmed, Hagel said, he would run the Pentagon guided by a long-held philosophy: “Is our policy worthy of our troops and their families and the sacrifices that we ask them to make?”

One of the first bruising lines of questioning came early, when Sen. John McCain (R-Ariz.) asked Hagel whether he regretted his opposition to the 2007 troop surge in Iraq.

“Were you right?” McCain asked sternly, eliciting a response that he seemed to find inadequate.

“I would defer to the judgment of history to sort that out,” Hagel said, refusing repeatedly to provide a yes-or-no answer.

Hagel later said that the Iraq war, including the surge, was the “most fundamentally bad, dangerous decision since Vietnam.”

Hagel faced relatively few nuanced questions about the Afghan war or terrorist threats. Afghanistan was mentioned just 27 times, and al-Qaeda only twice, while Israel got 178 mentions and Iran 169.

On Afghanistan, where 66,000 U.S. troops remain deployed, Hagel said he did not have enough knowledge about the war to have an informed opinion about the ideal size for the force the United States might leave behind after its combat mandate expires at the end of 2014. He agreed with a senator’s characterization that Obama intends to draw down troops “sooner rather than later.”

“I think he’s made that very clear,” Hagel said. “If I am confirmed, I will need to better understand all the dimensions of this.”

Senators spent a great deal of time pressing Hagel on his views on Iran, demanding to know why he has in the past rejected unilateral sanctions and why he refused to endorse an effort to designate the Iran’s Revolutionary Guard a terrorist organization.

The question elicited one of Hagel’s most damaging missteps, as he argued that it would have been unprecedented to add a military unit of an “elected, legitimate government” as a terrorist organization. Senators took exception to that characterization, which Hagel later softened. On the broader question of the best approach to reducing the threat Iran poses, the nominee defended some of his past positions.

“I think it’s always wise to try to talk to people before you get into war,” he said. He later added: “I never thought engagement is weakness.”

Hagel was also challenged about a comment he made in a newspaper interview in August 2011, in which he was quoted as saying that the Pentagon’s budget was bloated. On Thursday, he said he had made the comment before Congress passed a bill that imposed substantial defense cuts. The interview was, in fact, conducted after the bill’s passage.

The nominee said he would run the Pentagon in a fiscally responsible manner and rejected the claim that he favors the congressionally mandated across-the-board cuts that could kick in March 1 if the White House and Congress fail to reach a deal on debt reduction.

Hagel struggled when Sen. Lindsey O. Graham (R-S.C.) asked him to expand on his past assertion that the Israeli lobby “intimidates a lot of people” and challenged him to point to a single senator who feels intimidated.

“Name one,” Graham said, eliciting a meek response from Hagel, who said: “I do not know.”

Later in the hearing, Sen. Ted Cruz (R-Tex.) showed footage of interviews Hagel gave to the Qatar-based al-Jazeera television network that appeared to depict him as being sympathetic with viewers who said that Israel had committed war crimes and that the United States was the “world’s bully.” Hagel on Thursday sought to distance himself from both notions.

“I think my comment was it’s a relevant and good observation,” Hagel replied. “I don’t think I said I agree with it.”

Scott Wilson and Rajiv Chandrasekaran contributed to this report.