WASHINGTON — President Obama today relieved Afghanistan war commander Gen. Stanley McChrystal of his command following a private meeting at the White House, saying he “welcomes debate, but not division.”

McChrystal met privately with Obama at the White House this morning, then departed ahead of a scheduled war strategy session, after coming under fire for inflammatory comments he made in a Rolling Stone interview.

“I’ve got great admiration for him for his great service in uniform. … But war is greater than any one man or woman, whether a private, a general or president,” said Obama.

He said McChrystals’ comments “erodes the trust” needed to achieve “our objectives” in Afghanistan.

McChrystal said in statement that he resigned because of his “desire to see the mission succeed.”

Before the White House meeting, two military officials said McChrystal went in prepared to submit his resignation.

“It is my duty to ensure that no diversion complicates our mission,” Obama added, saying that this code applies to everyone and that he “welcomes debate, but not division.”

“Our democracy depends on institutions that are bigger than any person. … I believe that this decision is necessary,” Obama said, adding that a “unity of effort” is needed at this time.

Gen. David Petraeus has been named to replace McChrystal as commander, Obama said during his prepared remarks at the White House. The Senate needs to confirm Petraeus before he can be named commander of operations in Afghanistan.

Obama summoned McChrystal to Washington from Afghanistan after learning of his comments about administration officials.

Before today announcement, Afghan President Hamid Karzai expressed his confidence in McChrystal during a video conference Tuesday night with Obama, Karzai spokesman Waheed Omar said this morning in Kabul.

“We hope there is not a change of leadership of the international forces here in Afghanistan and that we continue to partner with Gen. McChrystal,” Omar told reporters.

In another statement, Karzai said he supports Obama’s decision.

In the Rolling Stone article, McChrystal didn’t criticize Obama himself but called the period last fall when the president was deciding whether to approve more troops “painful” and said Obama appeared ready to hand him an “unsellable” position.

McChrystal also said he was “betrayed” by Ambassador Karl Eikenberry, the man the White House chose to be his diplomatic partner in Afghanistan. He accused Eikenberry of raising doubts about Karzai only to give himself cover in case the U.S. effort failed. “Now, if we fail, they can say ‘I told you so,'” McChrystal told the magazine. And he was quoted mocking Vice President Joe Biden.

If not insubordination, the remarks — as well as even sharper commentary about Obama and his White House from several in McChrystal’s inner circle — were at least an indirect and extraordinary challenge and one that consumed Washington on Tuesday. The capital hasn’t seen a similar public contretemps between a president and a top wartime commander since Harry Truman stripped Gen. Douglas MacArthur of his command more than a half-century ago after disagreements over Korean War strategy.

Notably, neither McChrystal nor his team questioned the accuracy of the story or the quotes in it. McChrystal issued an apology.

Military leaders rarely challenge their commanders in chief publicly. When they do, consequences tend to be more severe than a scolding.

Wisconsin Democratic Rep. David Obey, chairman of the House Appropriations Committee, had called for McChrystal to resign.

Sen. John McCain, the top Republican on the Senate Armed Services Committee, was among three prominent Republican senators to criticize the general and say a decision about his future should rest with Obama.