The message from the president today was that everyone involved in the mission "needs to remember why we're doing this," the official said. "He doesn't want to see pettiness. This job isn't about personalities and reputations, it's about the men and women in uniform and serving our country."
It undermines the mission and the unity of the team implementing the policy -- including U.S. allies, such as the French, who were also disparaged by McChrystal and his team in the Rolling Stone story, the official added.
"This was a sad, tragic day," the official said.
McChrystal had informed Gates on Tuesday that he was prepared to resign, but contrary to reports Tuesday from other news outlets, he didn't offer his resignation until today, the official said.
After McChrystal left the White House, the president met for roughly 45 minutes with Gates, Vice President Biden, Chairman of the Joint Chiefs of Staff Admiral Mike Mullen, White House chief of staff Rahm Emanuel, and National Security Adviser Gen. James Jones to discuss next steps.
Immediately after that meeting, the president met with Petraeus and offered him the job.
"Petraeus had a sense that his name was being discussed," the official said.
The president also spoke to his Cabinet, key lawmakers and and Karzai to inform them of the decision.
McChrystal admitted during his round of phone calls to top Obama administration officials that he had "compromised the mission," a senior administration source told ABC News earlier today.
On Tuesday, Obama said McChrystal and his team showed "poor judgment," but that he wanted to meet with him face to face before making a decision on whether to fire him.
Officials feared that McChrystal's influence would be diminished and could jeopardize the momentum of the U.S. counterinsurgency strategy in Afghanistan. At the same time, officials realized how closely tied McChrystal was with the current counterinsurgency strategy, and the fact that Gen. David McKiernan was dismissed from the same job last summer could cause upheaval in operations on the ground.
The profile published in Rolling Stone, titled "The Runaway General," characterized McChrystal as an outsider who did not relate well with the administration, and as a military leader who was "disappointed" with his first meeting with the president.
Hastings said McChrystal was fully aware of the notebook and tape recorder that the freelance journalist always had in his interviews.
"It was a sort of natural kind of recklessness that General McCrystal had, that has been with him through his entire career, as I understand it, I hear from the special forces community," Hastings told ABC News' Diane Sawyer Tuesday. "Their willingness to take a risk is a part of their whole persona. And inviting me in, was a obviously a risk, as it always is when you invite a journalist in."
McChrystal and his aides criticized several top U.S. officials, including U.S. special envoy to Pakistan and Afghanistan Richard Holbrooke -- dubbed a "wounded animal." McChyrstal also said he felt betrayed by Eikenberry for the ambassador's criticism of Karzai in a leaked cable.
One of the article's most disparaging remarks comes from an unnamed adviser to McChrystal, who described the general's first meeting with Obama.