I am saddened to read about David Petraeus’s resignation as CIA Director, citing an extramarital affair. I know nothing about the circumstances and suspect we will learn more before long. What I do know is that the hyenas are now circling his political carcass, ready to rip him to shreds, now that he is already wounded. What I also know is that this is a depressing fate to befall one of America’s greatest generals—probably the greatest we have had since the World War II generation passed from the scene.

Imagine Winfield Scott, U.S. Grant, William Sherman, George Patton, Dwight Eisenhower or Matthew Ridgway resigning over an affair. It’s simply impossible to imagine; standards have changed so much over the years that now sexual peccadilloes are about the only thing that can bring down senior military commanders. Petraeus did not have as big a war to fight as his predecessors did but what he achieved in Iraq was one of the most impressive turnarounds ever seen in any counterinsurgency campaign that I am familiar with.

Field Marshal Gerald Templer’s success in Malaya in the 1950s is usually cited as the gold standard of counterinsurgency. Well Iraq in early 2007, when Petraeus took over as commander, was in far worse shape than Malaya in 1952 when Templer arrived on the scene. Few thought there was any chance of stopping Iraq’s slide into ever-more violent civil war. Certainly not with a mere 20,000 or so surge troops–numbers widely dismissed as inadequate for the size of the task. Petraeus did not bluster and he did not boast, but he arrived with a quiet confidence that he could still save the day–and he did.

He did not do it alone, needless to say. The contributions of Lt. Gen. Ray Odierno, the day to day operational commander, and Ambassador Ryan Crocker were particularly important–not to mention the firm backing of President George W. Bush. But the odds are that the surge would have failed were it not for the inspired leadership displayed by Petraeus.

He had already studied the principles of population-centric counterinsurgency; he had quite literally written the book on the subject. And he proceeded to implement everything he had learned not only from his study of history but from the more than two years he had previously spent in Iraq, first as commander of the 101st Airborne Division and then as the top general charged with training Iraqi forces. He faced not only multiple foes on the ground–most prominently Al Qaeda in Iraq and the Mahdist Army–but also constant sniping from the home front where some derided him as “General Betray Us.” Throughout the ordeal of 2007-2008 he stood firm, constantly pushing his subordinates to do better, while defending their conduct in a stream of media interviews and in pivotal congressional testimony that prevented anti-war legislators from pulling the plug prematurely on the entire effort.

I was privileged to see some glimpses of Petraeus in action, not only in Iraq but also later in Afghanistan; I served as an informal adviser to him in both places. Never have I seen more effective leadership in action. He was a maestro at using all the instruments of governmental power, combing multiple “lines of operation” to wage a war far more diffuse and harder to grasp than a conventional campaign. In Afghanistan he did not preside over the kind of quick turnaround he managed to pull off in Iraq but he once again, building on the fine work done by Gen. Stanley McChrystal, helped to implement a strategy that substantially improved the situation.

Petraeus spent most of the past decade deployed—first in Bosnia, then in Iraq, finally in Afghanistan. In between the last two commands he served as Central Command chief, constantly jetting around the Middle East to carry on high-level negotiations. He maintained a grueling pace that would have been hard to do for men half his age, yet he never seemed to flag, not even when he was treated for cancer.

Petraeus devoted his life to serving his country. Few have ever done it as well. He now deserves the thanks of a grateful nation—rather than obloquy that is more likely to be visited on him instead.