(Karen Bleier — AFP/Getty Images)

Members of the Senate Armed Services Committee on Tuesday used an appearance by Defense Secretary Leon Panetta and the chairman of the Joint Chiefs of Staff to express deep misgivings about the failure to reach an agreement with the Baghdad government, saying they feared the withdrawal of American personnel would lead to a rise in sectarian tensions and provide an opening to Iran.

And in sometimes pointed remarks, they questioned whether the administration had done enough to extend the U.S. military beyond the the end of the year.

“The truth is that this administration was committed to the complete withdrawal of U.S. troops from Iraq and they made it happen,” said Sen. John McCain (Ariz.), the panel’s ranking Republican.

Panetta, among the many administration officials who had repeatedly pressed the Iraqis to make up their minds, interjected: “Sen. McCain, that’s simply not true — you can believe that, but that’s not true.”

Panetta and the chairman of the Joint Chiefs of Staff, Gen. Martin Dempsey, said officials made every effort to strike an agreement with the Iraqi government. But, they said, when the Iraqis refused to grant immunity to U.S. military personnel after Dec. 31, they had no choice but to recommend a full withdrawal to President Obama.

“The bottom line is that this is not about us,” Panetta said. “It’s about what the Iraqis want to do and the decisions that they want to make. And so we have now an independent and sovereign country that can govern and secure itself, and hopefully, make the decisions that are in the interests of its people.”

About 16,000 U.S. diplomats and other civilians will remain in Iraq, with the State Department overseeing what is known as the Office of Security Cooperation-Iraq. Security will fall largely to contractors.

Lawmakers on Tuesday complained not only about the costs of using contractors, but the risks involved in doing so.

“Will these contractors be able to perform the function that they’re needed to perform?” Sen. Kelly Ayotte (R-N.H.) asked Panetta. “Can you assure this committee that the State Department will be able to perform this unprecedented task?”

As with the decision to pull out U.S. troops, Panetta said U.S. officials just didn’t see a better option.

“Are there going to be risks associated with the contractors?” the defense secretary said. “Yes, I think that is the case. Do we have any other alternatives? No.”

Panetta and Dempsey said there would be still be some counterterrorism training with Iraqi forces, and that there would be continued negotiations over the U.S. role in Iraq in the future.

Dempsey said it would be wrong to view what’s happening in U.S.-Iraqi relations as a “divorce.”

“It may feel that way,” he allowed, “because of the way ... the Iraqi government came to a decision.”