Obama, presiding over a 50-nation war coalition summit in his hometown, summed up the mood by saying the Afghanistan that will be left behind will be stable enough for them to depart -- essentially good enough after a decade of war-- but still loaded with troubles.
The war that began in the weeks after the Sept. 11, 2001, attacks will finish at the end of 2014.
"I don't think there's ever going to be an optimal point where we say, `This is all done. This is perfect. This is just the way we wanted it,"' Obama said as the NATO summit closed. "This is a process, and it's sometimes a messy process."
Obama never spoke of victory.
Afghan forces for the first time will take over the lead of the combat mission by the middle of 2013, a milestone moment in a long, costly transition of control. Even in a backup role, U.S. forces and all the rest will face surprise attacks and bombings until the war's end.
Wary of creating a vacuum in a volatile region, the nations also promised a lasting partnership with Afghanistan, meaning many years of contributing tax dollars, personnel and political capital after the end of their soldiers' combat.
The United States has already cut its own deal with Afghanistan along those lines, including a provision that allows U.S. military trainers and special forces to remain in Afghanistan after the war closes.
In an escalating election-year environment, Obama was as at the center of the action in Chicago, beaming and boasting about the city's performance in hosting the event. Noisy protesters loaded the city's streets at times, which Obama called just the kind of free expression NATO defends.
Tensions with Pakistan undermined some of the choreographed unity. Pakistan has not yet agreed to end the closure of key transit routes into Afghanistan -- retaliation for American airstrikes that accidentally killed 24 Pakistani soldiers months ago -- and the issue hung over the summit.
Obama had no official talks with Pakistani President Asif Ali Zardari, although the two chatted briefly. Obama spoke of progress on the standoff but he added: "I don't want to paper over real challenges there. There's no doubt that there have been tensions."
On Afghanistan, led by Obama, the partners are in essence staying the course. They stuck with a timeline long established and underscored that there will be no second-guessing the decision about when to leave.
Since 2010, they have been planning to finish the war at the end of 2014, even as moves by nations such as France to pull combat troops out early have tested the strength of the coalition. The shift to have Afghan forces take the lead of the combat mission next year has also been expected. Leaders presented it as a significant turning point in the war.
It will be "the moment when throughout Afghanistan people can look out and see their own troops and police stepping up to the challenge," said the NATO chief, Secretary-General Anders Fogh Rasmussen. What the world is poised to leave behind is an Afghanistan still riddled with poverty, corruption and political instability.
Yet, out of money and patience, the U.S.-led partnership said it is confident Afghanistan will be stable and prepared enough to at least be able to protect itself -- and, in turn, prevent its territory from becoming a launching pad for international terrorism.
Questioned about what will happen if Afghanistan eventually falls apart, Obama signaled there is no turning back. "I think that the timetable that we've established is a sound one, it is a responsible one. Are there risks involved in it? Absolutely."
British Prime Minister David Cameron said the leaders were "making a decisive and enduring commitment to the long-term future of Afghanistan. The message to the Afghan people is that we will not desert them. And the message to the insurgency is equally clear: You cannot win on the battlefield. You should stop fighting and start talking."
The political stakes are high for the U.S. president, who will go before voters in November with tens of thousands more troops in Afghanistan than when we took office. His emphasis will remain that he is methodically winding down the war after closing out the one in Iraq; U.S. voters desperate for better economic times have long stopped approving of the war mission.
NATO said it will keep providing "long-term political and practical support" to Afghanistan after 2014 but added: "This will not be a combat mission."
Despite the size of the coalition, the war remains a United States-dominated effort.
The U.S. has 90,000 of the 130,000 foreign forces in the war. Obama has pledged to shrink that to 68,000 by the end of September but has offered no details on the withdrawal pace after that, other than to say it will be gradual.
The fighting alliance called negotiation the key to ending the insurgency in Afghanistan, but avoided mentioning the Taliban by name. The insurgents walked away from U.S.-led talks in March, and urged the NATO nations to follow the lead of France in pledging to remove combat forces ahead of schedule. The alliance agreed on a fundraising goal to underwrite the Afghan armed forces after the international fighting forces depart.
The force of about 230,000 would cost about $4.1 billion annually -- the bulk of it paid by the United States and countries that have not been part of the fighting force.
U.S. and British officials said during the summit that pledges total about $1 billion a year so far and that fundraising is on track to make up the rest. French President Francois Hollande said the U.S. had requested a little less than $200 million but was non-committal, saying France was "not bound by what Germany or other countries might do."