A seven-week battle over the nomination of Chuck Hagel to head the Pentagon came to an end Tuesday.

By a 58-41 vote, the Senate confirmed Hagel to succeed Leon Panetta as defense secretary in a leadership change that comes just as the Pentagon is about to face its most serious budget problems since the 9/11 attacks.

The unanswered question, likely to be answered soon, is whether the Vietnam combat veteran and former Republican senator from Nebraska is up to the balancing act that will be required: trying to trim excess defense spending while still protecting military capabilities and readiness.

The Pentagon announced Hagel will be sworn in Wednesday morning.

Hagel's success as defense secretary may depend on his future relations with Congress, which could prove difficult.

Senior Republicans, including Rep. Buck McKeon of California, the House Armed Services Committee chairman, and Sen. James Inhofe of Oklahoma, ranking Republican member of the Senate Armed Services Committee, expressed a lack of confidence in Hagel during his confirmation battle. Both had urged the withdrawal of Hagel's nomination, saying there were more qualified people who could be easily confirmed for the post, including Deputy Defense Secretary Ashton Carter and Michèle Flournoy, the former undersecretary of defense for policy. Inhofe said Carter or Flournoy could be confirmed by the Senate "in a few minutes."

Sen. Dan Coats, R-Ind., who opposed Hagel's nomination, said the person heading the Defense Department "should be someone whose candidacy is neither controversial nor divisive" because broad support is needed to "serve effectively in this critical position."

"Over the last half century, no secretary of defense has been confirmed and taken office with more than three senators voting against him," Coats said. "In the history of this nation, none has ever been confirmed with more than 11 opposing votes."

"This could have been a unifying moment," said Sen. Roger Wicker, R-Miss., who noted that Panetta was confirmed by a unanimous vote in 2011.

Hagel will be Obama's second Republican in charge of the Pentagon. When Obama took office at the beginning of his first term, he kept President George W. Bush's defense secretary, Robert Gates, in the post.

Sen. Carl Levin, D-Mich., the Senate Armed Services Committee chairman, said Hagel will bring a lot to the job. "Sen. Hagel would be the first former enlisted man and the first veteran of the Vietnam War to serve as secretary of defense," Levin said. "It would be a positive message for our soldiers, sailors, airmen and Marines in harm's way around the world to know that one of their own holds the highest office in the Department of Defense."

For Sen. Jim Inhofe of Oklahoma, the Armed Services Committee's ranking Republican, Hagel's service is not a factor. "He has a brilliant military career," Inhofe said. "I look at my time in the Army and his time in the Army, and mine is very unimpressive."

Inhofe, a former private first class who served in 1957 and 1958, said he has policy differences with Hagel, including about the size of the military budget, support for sanctions against Iran and other issues.

Navy veteran Sen. Mark Kirk, R-Ill., said he could not support Hagel. "While I appreciate and respect Sen. Hagel's record of service to our country, especially as a decorated combat veteran, I cannot support his nomination."

Hagel's "past views and statements place him far outside the bipartisan mainstream on key issues like Iran sanctions, European designation of Hezbollah as a terrorist group and the U.S.-Israel relationship," Kirk said in a statement issued as he voted against the nomination.