It seems hard to fathom now, but only 15 months ago, Gen. David H. Petraeus stood at attention on a sunny Fort Myer parade ground, listening to his peers compare him to the most accomplished generals in American history. Cannons boomed, sending clouds of white smoke billowing into the air. A band played patriotic marches.

The moment was heady, the words intended for the ages.

“You now stand among the giants, not just in our time, but of all time, joining the likes of Grant and Pershing and Marshall and Eisenhower as one of the great battle captains,” Adm. Mike Mullen, the chairman of the Joint Chiefs of Staff, told Petraeus before the hundreds assembled to salute the departing general on the final day of his 37-year military career.

The affair that forced Petraeus to resign from the CIA in early November has done more than send him to an unexpected, early retirement. It has prompted a head-snapping reassessment of the general’s entire record in Iraq and Afghanistan. Once-smitten reporters have penned lengthy mea culpas of how they fell prey to Petraeus’s myth-making, claiming that his considerable charms blinded them to his battlefield shortcomings. Some historians, rushing to rejudgment, are asking whether he produced victory in Iraq or merely a palatable stalemate. A headline on a New York Times opinion piece went so far as to brand him “A Phony Hero for a Phony War.”

Here is a more balanced and, I hope, more accurate view: Petraeus was neither a conquering hero nor an empty suit. To view his military record through the lens of his personal failure merely serves to replace one myth with another.

I saw Petraeus up close in Iraq and Afghanistan. He helped roll back a civil war in Iraq that was killing thousands of civilians a month, building up the confidence of mid-level officers who were questioning the Army’s direction. He deserved many of the accolades that came his way. He wasn’t nearly the same general in Afghanistan, where he never came to know the country the way he did Iraq.

Petraeus caused his own fall from his post as director of the CIA. But his shortcomings in Afghanistan were a product of exhaustion, ego and a Pentagon and White House that pressed him to take a job for which he was not prepared. When the conditions were most bleak on the battlefield, the powers that be in Washington turned repeatedly to Petraeus.

“It is ludicrous,” said Eliot Cohen, a historian and senior State Department official in the George W. Bush administration. “The military’s bench was appallingly thin.”

When Petraeus took over in 2007 as the top general in Iraq, he had already spent one year as a commander in northern Iraq and 15 months as the head of the effort to build the country’s army and police force. His knowledge of the country was astonishing.

On a typical morning, he might pepper his staff with detailed questions about the status of a neighborhood bank branch that the Shiite-dominated Finance Ministry had shuttered to punish Sunnis. Iraqis depended on the banks for pension payments. Minutes later, he would ask about a downed electrical transmission tower south of Baghdad or the status of a mid-level Iraqi commander he wanted to replace.

“Petraeus understood Iraq from the most granular level to the most grand strategic,” said retired Lt. Col. Doug Ollivant, a senior counterinsurgency adviser in Iraq and Afghanistan. “He was monumentally well-prepared for that job.”

He wasn’t well-prepared for Afghanistan. Although he was quick to say that the two countries were different, he often tried to draw on the lessons of Iraq to make a point about the best way forward in Afghanistan.

Interviews with reporters almost always began with a leftover PowerPoint slide from his Iraq days, depicting his “Anaconda strategy” of using military, economic and political pressure to crush an insurgency. He talked about his Iraq experience with such frequency and enthusiasm that he drew eye-rolls from longtime Afghan hands.

Initially, Petraeus seemed to use the Anaconda slide to stall for time until he had a better understanding of the country, in which he had never served. He was thrust into command in Afghanistan after the sacking of Gen. Stanley A. McChrystal and had only hours to prepare for the job. But the busy graphic — consisting of concentric circles and a dozen arrows — remained a mainstay throughout his Afghan tour and was symptomatic of a larger problem: Petraeus’s Iraq experience often led him to misjudge the Afghan conflict.

When Petraeus took over in Iraq, a bloody sectarian war between Sunnis and Shiites gripped the country. Mutilated bodies were a common sight on the streets. Iraqis blocked the entrances to their neighborhoods with piles of debris and burned-out cars in an effort to keep out suicide bombers and roving death squads.

To stop the carnage, Petraeus placed his forces on the fault lines between the two warring groups. He funneled ammunition and money to more than 100,000Sunni former insurgents who realized they were losing the civil war and wanted to leave the resistance. The deal Petraeus struck with his former enemies infuriated the Iraqi prime minister but paid huge dividends.

Civilian deaths, which peaked at more than 3,500 a month, fell by more than 60 percent in the span of a year, and the big drop in violence helped convince a skeptical Congress and White House that Petraeus’s strategy was working.

In Afghanistan, violence levels were much lower than in Iraq, and most of Petraeus’s subordinate commanders believed that the predatory Afghan government, not the Taliban, was the main driver of the war.

Petraeus faced a choice: He could try to reform the government by wresting power from the most brutal warlords. Or he could focus on improving security by destroying Taliban insurgents, a strategy that meant cooperating with the warlords’ hated militias.

Following the Iraq blueprint, Petraeus picked security, producing only modest gains in the south. In other key areas, his embrace of the warlords drove aggrieved villagers to back the Taliban.

“He seemed to think that if you killed enough [enemy fighters], that would be good enough,” Ollivant said. “He brought that with him from Iraq.”

Moreover, Petraeus’s star turn in Iraq seemed to blind him to his own fallibility. Throughout his career, he had cultivated a larger-than-life persona built around physical toughness and academic rigor. He was the general with a Princeton doctorate who had been shot in the chest during a training exercise, had shattered his pelvis in a parachute accident and yet could run a sub-six-minute mile into his late 50s.

The mythology wasn’t entirely self-serving. By 2006, many soldiers in Iraq had lost confidence in their generals, who were slow to recognize the destructive power of the insurgency. Petraeus’s warrior-intellectual ethos helped mid-level officers feel better about themselves and their purpose. “Success will require discipline, fortitude and initiative — qualities that you have in abundance,” he told his troops upon taking command in Iraq. No one seemed to embody those traits more than Petraeus.

Post-Iraq, the Petraeus mythology took on a baroque quality. One often-repeated story had him visiting the hospital bed of a soldier who had been in a coma for three weeks. Petraeus called out “Currahee,” the battle cry of the soldier’s unit. “All of a sudden, the lieutenant, his stumps are banging up and down on the sheets, and his head is moving around,” Petraeus said in an interview with CBS News.

The general’s critics groused that he suddenly had added to his resume the power to bring soldiers back from the dead.

The hokey story might have masked a greater pain. The scale of the American deaths in World War II (more than 400,000) and Vietnam (more than 58,000) made it tougher for commanders to pause over each loss.

But when Petraeus was the top commander in Iraq and Afghanistan, most of his morning update briefings began with a photograph and short bio of a soldier or Marine killed under his command. In 2003, as the general in charge of the 101st Airborne Division, he knew most of the soldiers who died under his command by name and met with most of their parents, widows and children.

“Today’s commanders don’t have a psychological buffer like their predecessors,” said Cohen, the historian.

Petraeus had few close friends and displayed little emotion. Some colleagues jokingly compared him to Spock, the character from “Star Trek” whose race had learned to suppress feelings. That, too, was a myth.

Petraeus clearly felt the weight of the casualties that occurred on his watch. “I almost think sometimes there’s sort of a bad-news vessel, and it’s got holes in the bottom, and then it drains,” he told author David Finkel during a 2007 interview in Iraq. “In other words, you know, it’s really your emotions, but I mean there’s so much bad news you can take. And it fills up. But if you have some good days, it sort of drains away.”

All armies eventually break under the strain of long wars. The strongest leaders leave, and discipline falters. Petraeus’s experience over the past decade shows that generals are not immune to the strain. They get used up, too.

Greg Jaffe has covered the military for The Washington Post since 2009.

Read more from Outlook, friend us on Facebook, and follow us on Twitter.