The vote was 58-41, with four Republicans joining the Democrats in backing the contentious choice. Hagel's only GOP support came from former colleagues Thad Cochran of Mississippi and Dick Shelby of Alabama as well as Mike Johanns of Nebraska and Rand Paul of Kentucky.
The vote came just hours after Republicans dropped their delay of the nomination and allowed it to move forward on a 71-27 vote.
Hagel, 66, a former two-term Nebraska senator and twice-wounded Vietnam combat veteran, succeeds Defense Secretary Leon Panetta. Hagel is expected to be sworn in at the Pentagon on Wednesday.
Republicans had opposed their onetime colleague, casting him as unqualified for the job, hostile toward Israel and soft on Iran.
Republican Sen. John McCain of Arizona said several GOP lawmakers had "a lot of ill will" toward the moderate Republican for his criticism of President George W. Bush over the Iraq war and his backing for Democratic candidates. McCain voted against his onetime friend and fellow Vietnam veteran.
Obama portrayed the war-tested Hagel as a man who understands that conflict is not an abstraction and called him the "leader that our troops deserve."
Hagel joins Obama's retooled second-term, national security team of Secretary of State John Kerry and CIA Director-designate John Brennan at a time of uncertainty for a military emerging from two wars and fighting worldwide terrorism with smaller, deficit-driven budgets.
Among his daunting challenges are deciding on troop levels in Afghanistan as the United States winds down its combat presence and dealing with $46 billion in budget cuts set to kick in on Friday. He also will have to work with lawmakers who spent weeks vilifying him.
Republicans insisted that Hagel was battered and bloodied after their repeated attacks.
"He will take office with the weakest support of any defense secretary in modern history, which will make him less effective on his job," said Sen. John Cornyn of Texas, the Senate GOP's No. 2 Republican.
Not so, said Democratic Sen. Jack Reed, who pointed out that Hagel now has the title and the fight is history.
"All have to work together for the interest of the country," said Reed, D-R.I.
The vote ended one of the most bitter fights over a Cabinet choice and former senator since 1989 when the Democratic-led Senate defeated newly elected President George H.W. Bush's nomination of Republican John Tower to be defense secretary.
In the course of the rancorous, seven-week nomination fight, Republicans, led by freshman Sen. Ted Cruz of Texas and Sen. Jim Inhofe of Oklahoma, insinuated that Hagel has a cozy relationship with Iran and received payments for speeches from extreme or radical groups. Those comments drew a rebuke from Democrats and some Republicans.
Sen. Carl Levin, D-Mich., the chairman of the Armed Services Committee, dismissed the "unfair innuendoes" against Hagel and called him an "outstanding American patriot" whose background as an enlisted soldier would send a positive message to the nation's servicemen and women.
Sen. Claire McCaskill, D-Mo., questioned how the confirmation process devolved into a character assassination in which Hagel was accused of "having secret ties with our enemies."
"I sincerely hope that the practice of challenging nominations with innuendo and inference, rather than facts and figures, was an aberration and not a roadmap," she said in a statement after the vote.
Obama got no points with the GOP for tapping the former two-term Republican senator. Republican lawmakers excoriated Hagel and cast him as a radical far out of the mainstream.
McCain clashed with his onetime friend over his opposition to Bush's decision to send an extra 30,000 troops to Iraq in 2007 at a point when the war seemed in danger of being lost. Hagel, who voted to authorize military force in Iraq, later opposed the conflict, comparing it to Vietnam and arguing that it shifted the focus from Afghanistan.
Republicans also challenged Hagel about a May 2012 study that he co-authored for the advocacy group Global Zero, which called for an 80 percent reduction of U.S. nuclear weapons and the eventual elimination of all the world's nuclear arms.
The group argued that with the Cold War over, the United States could reduce its total nuclear arsenal to 900 without sacrificing security. Currently, the U.S. and Russia have about 5,000 warheads each, either deployed or in reserve. Both countries are on track to reduce their deployed strategic warheads to 1,550 by 2018, the number set in the New START treaty that the Senate ratified in December 2010.
In an echo of the 2012 presidential campaign, Hagel faced an onslaught of criticism by well-funded, Republican-leaning outside groups that labeled the former senator "anti-Israel" and pressured senators to oppose the nomination. The groups ran television and print ads criticizing Hagel.
Opponents were particularly incensed by Hagel's use of the term "Jewish lobby" to refer to pro-Israel groups. He apologized, saying he should have used another term and should not have said those groups have intimidated members of the Senate into favoring actions contrary to U.S. interests.
The nominee spent weeks reaching out to members of the Senate, meeting individually with lawmakers to address their concerns and seeking to reassure them about his policies.
Hagel's inconsistent performance during some eight hours of testimony during his confirmation hearing last month undercut his cause.
On Feb. 12, the Armed Services Committee approved the nomination on a party-line vote of 14-11. Two days later, a Democratic move to vote on the nomination fell a few votes short as Republicans insisted they needed more time to consider the pick.
Hagel's nomination also became entangled in Republican demands for more information about the deadly assault on the U.S. diplomatic mission in Benghazi, Libya, last September. Ambassador Chris Stevens and three other Americans were killed in that attack.
More Nation & World Headlines
Votes now in hand for Obama victory on Iran deal Pope’s decree on abortion may signal change in tone, not practice Home detention for white police chief who shot black man Missouri executes man for 15-year-old girl’s 1989 killing Obese at 50? Midlife weight may affect when Alzheimer’s hits Police in Georgia responding to wrong house shoot dog, homeowner Bush-Trump dispute intensifies, Bush hitting back harder California to end unlimited isolation for most gang leaders
Our new comment system is not supported in IE 7. Please upgrade your browser here.