But Mr. Hagel's aides had maintained in recent weeks that he expected to serve the full four years as defense secretary. His removal appears to be an effort by the White House to show that it is sensitive to critics who have pointed to stumbles in the government's early response to several national security issues, including the Ebola crisis and the threat posed by the Islamic State.
Even before the announcement of Mr. Hagel's removal, Obama officials were speculating on his possible replacement. At the top of the list are Michèle A. Flournoy, a former under secretary of defense; Senator Jack Reed, Democrat of Rhode Island and a former officer with the Army's 82nd Airborne; and Ashton B. Carter, a former deputy secretary of defense.
Read MoreOp-Ed: The intellectual battle against ISIS
A respected former senator who struck a friendship with Mr. Obama when they were both critics of the Iraq war from positions on the Senate Foreign Relations Committee, Mr. Hagel has nonetheless had trouble penetrating the tight team of former campaign aides and advisers who form Mr. Obama's closely knit set of loyalists. Senior administration officials have characterized him as quiet during cabinet meetings; Mr. Hagel's defenders said that he waited until he was alone with the president before sharing his views, the better to avoid leaks.
Whatever the case, Mr. Hagel struggled to fit in with Mr. Obama's close circle and was viewed as never gaining traction in the administration after a bruising confirmation fight among his old Senate colleagues, during which he was criticized for seeming tentative in his responses to sharp questions.
He never really shed that pall after arriving at the Pentagon, and in the past few months he has largely ceded the stage to the chairman of the Joint Chiefs of Staff, Gen. Martin E. Dempsey, who officials said initially won the confidence of Mr. Obama with his recommendation of military action against the Islamic State.
Read MoreISIS launches own currency
In Mr. Hagel's less than two years on the job, his detractors said he struggled to inspire confidence at the Pentagon in the manner of his predecessors, especially Robert M. Gates. But several of Mr. Obama's top advisers over the past few months have also acknowledged privately that the president did not want another high-profile defense secretary in the mold of Mr. Gates, who went on to write a memoir of his years with Mr. Obama in which he sharply criticized the president. Mr. Hagel, they said, in many ways was exactly the kind of defense secretary whom the president, after battling the military during his first term, wanted.
Mr. Hagel, for his part, spent his time on the job largely carrying out Mr. Obama's stated wishes on matters like bringing back American troops from Afghanistan and trimming the Pentagon budget, with little pushback. He did manage to inspire loyalty among enlisted soldiers and often seemed at his most confident when talking to troops or sharing wartime experiences as a Vietnam veteran.
But Mr. Hagel has often had problems articulating his thoughts — or administration policy — in an effective manner, and has sometimes left reporters struggling to describe what he has said in news conferences. In his side-by-side appearances with both General Dempsey and Secretary of State John Kerry, Mr. Hagel, a decorated Vietnam veteran and the first former enlisted combat soldier to be defense secretary, has often been upstaged.
He raised the ire of the White House in August as the administration was ramping up its strategy to fight the Islamic State, directly contradicting the president, who months before had likened the Sunni militant group to a junior varsity basketball squad. Mr. Hagel, facing reporters in his now-familiar role next to General Dempsey, called the Islamic State an "imminent threat to every interest we have," adding, "This is beyond anything that we've seen." White House officials later said they viewed those comments as unhelpful, although the administration still appears to be struggling to define just how large is the threat posed by the Islamic State.