Chuck Hagel’s painful, prolonged and divisive nomination battle in the Senate finally ended Tuesday, but it is only a prelude to the national-security challenges that will greet him on his first day of work at the Pentagon.

Hagel was sworn in Wednesday as secretary of defense, after scraping together enough support to win Senate confirmation by a 58 to 41 vote. Until the very end, he had to overcome fierce opposition from pro-Israel groups and a filibuster led by fellow Republicans who neither forgot nor forgave his withering criticism of the George W. Bush administration’s handling of the war in Iraq.

The Vietnam combat veteran will have less than 48 hours to move into his new office in the outer ring of the Pentagon before he probably will have to confront an even tougher challenge: slashing $46 billion in military spending — about 9 percent of the defense budget — by the end of September.

Unless President Obama and Congress can conjure a last-minute deal, automatic budget cuts will start to take effect Friday. Most government agencies will be affected, but the Pentagon will take the biggest hit.

Hagel, a former two-term senator from Nebraska, will be forced to make some snap decisions about which military programs to preserve and which to sacrifice. Already, defense officials have said they may have to furlough up to 800,000 civilians, drastically scale back training and keep ships in port, including an aircraft carrier strike group that was bound for the Persian Gulf.

“He’ll have to go through and make decisions on each and every one of those,” said William S. Cohen, a Republican who served as defense secretary in the Clinton administration. “I assume he’s been drinking from the fire hose already.”

On a personal level, Hagel will also have to quickly put aside any bruised feelings from an unusually bitter confirmation process. His foremost political task will be to sit down with Republican lawmakers who denounced his candidacy and persuade them to reach a compromise with Democrats to restore the Pentagon’s budget.

In a statement after the vote, Hagel said he was honored and promised to “work closely with Congress to ensure that we maintain the strongest military in the world.”

But Republicans who opposed Hagel gave little indication that they would give him a break.

“He will take office with the weakest support of any defense secretary in modern history, which will make him less effective in his job,” said Sen. John Cornyn (Tex.), the second-ranking Republican in the chamber.

Pentagon officials already had to face questions about whether their new boss was a wounded duck.

“He understands the importance of healthy debate,” Pentagon press secretary George Little said. “And I think he is going to come in with the philosophy that he is going to be a team player inside this building, and that will extend to the United States Congress.”

The White House faces a second confirmation battle over Obama’s pick to lead the CIA, counterterrorism adviser John O. Brennan. Trying to clear Brennan’s path, the White House provided Congress with internal CIA e-mails and other documents related to the attack on U.S. diplomatic facilities in Benghazi, Libya, last year.

The Senate Intelligence Committee reviewed the material in a classified session Tuesday. Several Republicans said Brennan was involved in crafting controversial talking points on Benghazi, but Sen. Dianne Feinstein (D-Calif.), the committee chairman, said she did not think the material would play a part in Brennan’s confirmation. The panel could send the nomination to the full Senate as soon as Thursday.

Hagel’s rough road to confirmation was unusual. Leon M. Panetta, the outgoing defense secretary, was approved by a vote of 100 to 0. Prior to Hagel, no defense nominee had run into trouble since 1989, when former senator John Tower (R-Tex.) was defeated in a party-line vote amid revelations of womanizing and heavy drinking.

Hagel’s personal conduct was never questioned. His supporters touted his bravery as a combat infantryman in Vietnam, where he was awarded two Purple Hearts. As a Republican, he gave Obama an opportunity to claim a measure of bipartisanship in his Cabinet and was initially seen as a lock for Senate approval.

But the White House underestimated the degree to which Hagel had alienated his former GOP colleagues. John McCain (Ariz.) and James M. Inhofe (Okla.), influential Republicans on the Senate Armed Services Committee, insisted throughout the confirmation battle that Hagel was still a “friend” but criticized him as unqualified, uninformed and ill prepared to lead the Pentagon.

On Tuesday, Inhofe said he still had “serious concerns” but softened his criticism a touch, pledging to work with Hagel to avert military spending cuts. “It is my hope that Senator Hagel will not want to be known as the secretary of defense responsible for overseeing the gutting of our military,” Inhofe said.

Hagel did not help his cause with a mediocre performance during his confirmation hearing. Supporters said he was already working hard to erase the episode from memory and predicted he would soon reach out to repair relations in the Senate.

“It’s a two-way street,” said Sen. Jack Reed (D-R.I.), who also sits on the Armed Services Committee. “He’s already had many conversations. Obviously there has to be communication. It has to be honest, civil but honest. And I’m confident that will happen.”

Apart from politics, Reed and other backers acknowledged that Hagel has his work cut out for him in managing the Pentagon, with its 2.2 million employees, a tricky withdrawal from Afghanistan and a fiscal crisis.

“He has got probably the best preparation one can have, given his military and executive and legislative experience,” Reed said. “But it is a very daunting time.”

Thomas Donnelly, a defense and security analyst at the American Enterprise Institute, a conservative think tank, predicted that Hagel would wield minimal clout. He said the Obama administration dictates national-security policy from the White House and has marginalized the secretary of defense into a “ceremonial” job.

“It’s a slight exaggeration to say that,” Donnelly said. “It should be an important job. But if the White House is calling all the shots, there’s not much left for the secretary to do.”