“Tom’s that rare combination of the strategic and the tactical. He has a strategic sense of where we need to go, and he has a tactical sense of how to get there,” Mr. Obama said in his announcement. “He’s helped shape every single national security policy of my presidency, from forging a new national security strategy rooted in our economic strength here at home to ending the war in Iraq.”

Among Mr. Donilon’s last big projects was negotiating the highly unusual informal meeting between Mr. Obama and President Xi Jinping of China on Friday at an estate in Southern California. Just back from talks in Beijing, he clearly took pride of ownership.

“I don’t know when there was a broad meeting like this,” Mr. Donilon said in an interview. “For the last 40 years or so, these conversations have taken place in a more formal, scripted context.”

But Mr. Donilon has also hit a rough patch recently, with the publication of an unflattering profile in Foreign Policy magazine that cast him as a sharp-elbowed infighter and a domineering boss who had strained relationships with colleagues, including his former deputy, Denis R. McDonough, now the White House chief of staff.

Mr. Donilon and Mr. McDonough, however, both denied those reports. Mr. McDonough said he had a “very good relationship with Tom,” adding, “It pains me to think anybody would think he’s leaving because of me.”

Mr. Donilon, whose departure is effective in early July, said he had planned to leave after Mr. Obama’s first term but stayed on at the president’s request to break in a new team led by Secretary of State John Kerry, Defense Secretary Chuck Hagel, and the director of the Central Intelligence Agency, John O. Brennan.