This is the outcome that Obama probably wanted all along, which was favored back in 2009 by Vice President Biden and other political advisers. The president let himself be talked into a more ambitious counterinsurgency strategy, and a surge of 30,000 troops, but he never seemed happy with it. Indeed, he undercut the surge strategy from the outset by announcing that he would begin withdrawing the surge troops in July 2011 — practically inviting the Taliban to wait him out.

Obama has sometimes seemed a distant, passionless commander, much more comfortable making decisions in secret about covert action than in the flag-waving public role of leading the troops. But that didn’t seem true yesterday, especially during his unscripted, shirt-sleeve speech to troops at Bagram Air Base. He sounded like the military’s advocate and leader, looking fit and youthful as he strode striding the stage. Surely this comfort level was a reflection of the fact that he was outlining a strategy he finally believes in.

Obama’s speech in Kabul was at once about ending the war, in the sense of stopping the lead U.S. combat role next year, and continuing the war with a much smaller counterterrorism force of up to 20,000 troops that could stay in Afghanistan for 10 years after the main U.S. force leaves in 2014. This residual presence means the Taliban may lose its bet about waiting out the U.S. presence — which is good for Afghanistan and also for the coherence and credibility of U.S. policy.

The signature line of Obama’s prime-time speech from Afghanistan struck this theme of war’s end: “We have traveled through more than a decade under the dark cloud of war,” the president said. “In the pre-dawn darkness of Afghanistan, we can see the light of a new day on the horizon.”

But on his trip, Obama also signed a “strategic partnership document” with Afghan President Hamid Karzai that allows for the U.S. residual CT force. This document may be the most important commitment Obama has yet made to stabilizing Afghanistan, precisely because it is sustainable and enduring, rather than short-term, conditional and deadline-limited.

The Afghanistan trip obviously was a preview of arguments Obama will make during the coming presidential campaign: He is the president who ended a decade of expeditionary wars; he is the president who killed Osama bin Laden; he is the president who found a way to leave Afghanistan but also stay. For a president who sometimes likes to be on both sides of a question — and not unreasonably so, when they are hard problems, defying easy solutions — this was a defining trip.