“I actually would like an answer, yes or no,” Mr. McCain said.

“Well, I’m not going to give you a yes or no,” Mr. Hagel replied.

Mr. McCain did not let up.

“I think history has already made a judgment about the surge, sir, and you’re on the wrong side of it,” Mr. McCain said. “And your refusal to answer whether you were right or wrong about it is going to have an impact on my judgment as to whether I vote for your confirmation or not.”

It took the next questioner, Senator Bill Nelson, Democrat of Florida, to draw Mr. Hagel out on the subject. “I did question a surge,” Mr. Hagel said. “I always ask the question, is this going to be worth the sacrifice?”

He said that nearly 1,200 American men and women had lost their lives in the surge and that thousands more were wounded. “I’m not that certain that it was required,” Mr. Hagel said. “Now, it doesn’t mean I’m right, doesn’t mean I didn’t make wrong votes.”

One of the most hostile questioners was Senator Lindsey Graham of South Carolina, who told Mr. Hagel to “name one dumb thing we’ve been goaded into doing because of the pressure from the Israeli or Jewish lobby.” Mr. Hagel, who in 2006 said that the “Jewish lobby” intimidates Congress, could not.

Senator Ted Cruz, Republican of Texas, surprised the hearing when he put excerpts from an interview Mr. Hagel gave to Al Jazeera in 2009 on a giant video screen. Although it was difficult to hear the short clips he provided, Mr. Cruz asserted that they showed Mr. Hagel agreeing with a caller who suggested that Israel had committed war crimes.

“Do you think the nation of Israel has committed war crimes?” Mr. Cruz demanded.

“No, I do not, Senator,” Mr. Hagel replied.