Mr. Earnest was one of two top candidates for the job, along with Jen Psaki, who was campaign press secretary for Mr. Obama in 2012 and is now the spokeswoman for the State Department. The White House decided to keep Ms. Psaki there, people with knowledge of the process said, because she has close ties with Secretary of State John Kerry.

Image Mr. Carney Credit... Alex Wong/Getty Images

The choice of Mr. Carney as press secretary put a seasoned White House correspondent on the other side of the cameras. A 21-year veteran of Time magazine, Mr. Carney proved to be a fierce advocate for the administration — first for Vice President Joseph R. Biden Jr., for whom he was communications director, and then for the president.

While Mr. Carney was not part of Mr. Obama’s inner circle, he developed an easy rapport with the president, even playing cards on Air Force One. David Axelrod, a former political adviser to the president, described Mr. Carney as a “consummate professional, smart and unflappable.”

Dan Pfeiffer, Mr. Obama’s senior adviser, said: “Jay walked the high-wire under the live fire of the press in the Twitter age and never stumbled. That is the spokesperson equivalent of DiMaggio’s hitting streak.”

Though Mr. Carney often frustrated reporters — he said he appreciated tough questions, while referring the questioner to other government agencies — he rarely made a gaffe.

“Journalists have not made the best press secretaries, but Jay has shown respect for reporters and their professional needs,” said Ann Compton, a longtime White House correspondent for ABC News.