WASHINGTON – The White House decision to order Afghanistan commander Army Gen. Stanley McChrystal on Tuesday to leave a flailing war and answer to President Barack Obama about comments he and aides made in a forthcoming magazine article culminates months of tension between the military and political leadership over how to conduct the war.

The friction between the military leadership and the Obama administration began almost immediately after the president took office last year and has grown as the situation in Afghanistan has deteriorated.

It reached its apex in December, when Obama gave an address at the U.S. Military Academy at West Point, N.Y., and set a date — July 2011 — for American troops to start withdrawing, which goes against the principles of counterinsurgency that guided the military in the latter part of the Iraq war.

Military commanders said privately that the White House didn’t understand war; White House officials said the military didn’t understand political realities.

Political leaders have intimated for months that the Pentagon has engaged in leaks and backroom insubordination. Military leaders have said the Obama administration is committed to getting out of Afghanistan, not winning.

Where the military has called for leaving a stable Afghanistan, civilian leaders have said they want only to “disrupt, defeat and dismantle” al-Qaida.

In the Rolling Stone magazine article, scheduled for release Friday, a McChrystal aide ridicules Vice President Joe Biden, who had opposed the troop “surge” for Afghanistan. Another aide described Richard Holbrooke, the U.S. special envoy for Afghanistan and Pakistan, as a “wounded animal.”

McChrystal is quoted as saying that the U.S. ambassador in Kabul, Karl Eikenberry, who wrote an e-mail opposing the additional troops, “covers his flank for the history books.”

A McChrystal aide calls national security adviser Jim Jones, a retired Marine general, a “clown.” Only Secretary of State Hillary Clinton gets good reviews from McChrystal’s staff.

Aides to McChrystal have made the same complaints privately for months. Indeed, in a statement Tuesday about the article, McChrystal didn’t question the accuracy of the story but instead offered his “sincerest apology.”

“It was a mistake reflecting poor judgment and should never have happened. Throughout my career, I have lived by the principles of personal honor and professional integrity. What is reflected in this article falls far short of that standard,” McChrystal said.

“I have enormous respect and admiration for President Obama and his national security team, and for the civilian leaders and troops fighting this war, and I remain committed to ensuring its successful outcome.”

One of McChrystal’s key aides, public affairs adviser Duncan Boothby, resigned Tuesday.

Today, McChrystal will attend a weekly White House meeting on Afghanistan and Pakistan; he usually participates by video teleconference.

At the Pentagon, commanders began speculating over McChrystal’s possible replacement, conceding that the bench is short. At the top of the list is Marine Gen. James Mattis, the commander of the U.S. Joint Forces Command, who was just passed over to replace Gen. James Conway as the next Marine Corps commandant.

Tensions began months into the new administration when top defense officials came to Obama and recommended that he fire then-Afghanistan commander Army Gen. David McKiernan and replace him with McChrystal. The military also said it needed 21,500 more troops, and Obama agreed. Pentagon officials say Obama felt cornered by a war he didn’t understand.

Upon becoming commander, McChrystal conducted a 90-day review and concluded that he needed as many as 80,000 more troops. The administration, which had once said that the commander would get what he needed, instead publicly squabbled for months before agreeing to send another 30,000 troops, 50,000 short of the request.

In addition, the Obama administration announced that the commander had until December — four months after the completion of the troop surge — to show progress. July 2011, the start of the 2012 political cycle, a withdrawal would begin.

The Pentagon tried to adjust its position to the White House timetable. Secretary of Defense Robert Gates, who’d opposed timelines in a counterinsurgency when he served under the George W. Bush administration, said he supported this one because it created a sense of urgency among Afghans.

The uniformed military, however, never embraced the deadline. Instead, military officers say the Afghan government and neighboring countries assume that the United States will abandon them and are making alliances around the American military, not working alongside it.

Just last week, Army Gen. David Petraeus, the commander of U.S. Central Command, appeared on Capitol Hill and answered questions about whether he supported the July 2011 withdrawal timeline with a “qualified yes.”

In hopes of reassuring its allies in the region, Pentagon officials have suggested that the withdrawal will be gradual and “conditions-based,” and that the U.S. military presence will remain until Afghanistan is stable. However, Biden also told a reporter that “in July of 2011, you are going to see a whole lot of people moving out. Bet on it.”

The war effort continued flailing. U.S. troop deaths rose, and the Taliban’s hold in Afghanistan kept expanding as NATO members such as Britain, Germany and Canada sought ways to reduce their presence in the country.

McChrystal launched an offensive in the southern city of Marjah in February to eliminate a Taliban stronghold. Weeks after the operation, the Taliban reappeared in the town. The U.S. military had planned a major offensive this month in the southern city of Kandahar, Afghanistan’s largest city. The military since has tried to lower expectations of that effort, however.

The troop surge was supposed to include a civilian component but remains under-resourced. In addition, the military is short 450 trainers in its effort to build up the Afghan army and police.

In a White House briefing Tuesday, deputy press secretary Bill Burton said the president remained committed to the July 2011 timetable to start drawing down troops, but he noted that Obama also said he’d review those plans late this year.

If Obama accepts McChrystal’s resignation or fires him, it would be the second time under Gates’ tenure that a high-ranking military official has resigned over controversial comments made in a magazine piece.

In March 2008, then-CENTCOM commander Adm. William “Fox” Fallon resigned over remarks he made to Esquire magazine criticizing the Bush administration.

Gates replaced him with Petraeus.