Sen. John McCain, R-Ariz., clashed with his onetime friend over his opposition to President George W. 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.
McCain said several GOP lawmakers also had "a lot of ill will" toward the moderate Republican for his criticism of Bush and his backing for Democratic candidates.
Shortly after a White House meeting with Obama on immigration on Tuesday, McCain voted against his onetime friend and fellow Vietnam veteran.
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.
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.
Republicans allowed the nomination to move forward, with 18 Republicans joining the Democrats. Many had warned against the precedent of denying a president his Cabinet choices.
Paul's vote for Hagel came as something of a surprise. Moira Bagley, a spokeswoman for the senator, said that while he disagrees with Hagel on a number of issues, Paul believes a president should have some leeway in his political appointments.
Missing the vote was Democratic Sen. Frank Lautenberg of New Jersey.
Follow Donna Cassata on Twitter: http://twitter.com/DonnaCassataAP