In speech from Bagram, Obama vows to end war but not abandon Afghanistan

President Barack Obama, on a surprise nighttime trip to Afghanistan, told war-weary Americans that he would keep his promise to wind down the unpopular conflict by the end of 2014 but also vowed he would not abandon the strife-torn country prematurely.

In a televised address from an aircraft hangar at Bagram Air Base, Obama said the daring raid that killed Osama bin Laden exactly one year ago meant that the goal of crushing the al-Qaida network was "now within our reach."

"I recognize that many Americans are tired of war," Obama said. "I will not keep Americans in harm's way a single day longer than is absolutely required for our national security. But we must finish the job we started in Afghanistan and end this war responsibly."

Obama, speaking at 4 a.m. local time, highlighted a new security agreement both he and Afghan President Hamid Karzai had signed hours earlier to usher in "a future in which the war ends, and a new chapter begins."

Obama had a message for those, mostly Republicans, who question his timetable for withdrawal and argue that it risks emboldening the Taliban and their al-Qaida and other extremist allies while demoralizing America's Afghan friends.

"Our goal is to destroy al-Qaida, and we are on a path to do exactly that," he said. "Afghans want to fully assert their sovereignty and build a lasting peace. That requires a clear timeline to wind down the war."

But he also took aim at those, mostly Democrats but a growing number of conservatives, who no longer see a clear purpose to America's longest war and "will ask why we don't leave immediately."

"That answer is also clear: we must give Afghanistan the opportunity to stabilize," the president said from behind a podium emblazoned with his official seal, with several armored vehicles parked behind him. "Otherwise, our gains could be lost, and al-Qaida could establish itself once more. And as commander-in-chief, I refuse to let that happen,"

Obama, already taking fire from the presumptive Republican presidential nominee Mitt Romney, also offered a broader, ringing defense of his overall stewardship of the "war on terrorism" he inherited from George W. Bush."My fellow Americans, we have traveled through more than a decade under the dark cloud of war. Yet here, in the pre-dawn darkness of Afghanistan, we can see the light of a new day on the horizon," he declared.

"The Iraq war is over. The number of our troops in harm's way has been cut in half, and more will be coming home soon. We have a clear path to fulfill our mission in Afghanistan, while delivering justice to al Qaeda," he said.

"This time of war began in Afghanistan, and this is where it will end," he predicted.

Earlier, Obama thanked the troops in the field by radio, and visited the base's hospital, where he awarded 10 Purple Hearts.

The independent group puts overall NATO coalition casualties in "Operation Enduring Freedom" since 2001 at 2,985, with 1,957 of them Americans. More than 15,000 Americans have been wounded over the same period.

The long-term pact, the fruit of nearly two years of talks, emphasized that the United States did not seek permanent military bases in Afghanistan but would operate from Afghan facilities. The agreement also allows for an unspecificed number of American forces to remain past 2014 to train their local counterparts and target al-Qaida. And it commits Washington to designating Kabul a "major non-NATO Ally," a special status that makes it easier to provide military aid.

"Within this framework, we will work with the Afghans to determine what support they need to accomplish two narrow security missions beyond 2014: counter-terrorism and continued training," the president said. "But we will not build permanent bases in this country, nor will we be patrolling its cities and mountains. That will be the job of the Afghan people."

Obama predicted that NATO leaders would embrace the plan when they meet in Chicago later this month. They will lay out goals for the handover of security responsibility to Afghan forces, he said, ultimately enabling most allied forces to withdraw.

"Still, there will be difficult days ahead. The enormous sacrifices of our men and women are not over," he warned.

The partnership deal reportedly gives Afghans control over prisoners and makes night raids--a frequent source of Afghan resentment and anger--subject to approval from the Afghan government.

The president left Andrews Air Force Base, home to his blue and white liveried Air Force One, at 12:09 a.m. Tuesday morning and landed at Bagram at 10:20 p.m. local time. He then took a helicopter to the presidential palace in Kabul, where he arrived just after 11 p.m. local.

[Related: Inside Obama's secret trip to Afghanistan]

The unannounced trip recalled President George W. Bush's Thanksgiving 2003 trip to Iraq, a cloak-and-dagger operation that saw him sneak off his Texas ranch, fly to Washington and then on to Baghdad with a small group of aides and reporters. Obama's visit also comes on the ninth anniversary of Bush's "Mission Accomplished" speech about the Iraq war, a cautionary tale for any president tempted to take a "victory lap" in wartime.

Obama previously visited Afghanistan in March 2010 and December 2010, and traveled to Iraq in April 2009. Bush visited Iraq in November 2003, June 2006, and September 2007, and traveled to Afghanistan in March 2006. In December 2008, Bush visited Iraq and Afghanistan.

The secrecy surrounding the trip--a news blackout, arriving in darkness--highlighted the grim security situation in Afghanistan 11 ½ years after American soldiers invaded in the aftermath of the September 11, 2001, terrorist strikes.

The visit came as the Pentagon released an Afghanistan war progress report that highlights "both long-term and acute challenges" of the conflict, and warns that the Taliban and their al-Qaida allies "still operate with impunity from sanctuaries in Pakistan."

"The insurgency's safe haven in Pakistan, as well as the limited capacity of the Afghan government, remain the biggest risks to the process of turning security gains into a durable and sustainable Afghanistan," according to the report.

The Pentagon cited "shocks" like the slaughter of 17 Afghan civilians, allegedly by an American soldier, but reported that insurgent attacks had decreased 9 percent in 2011 from 2010, the first ebb in five years. It also reported that Afghan security forces, while improving, still face challenges from rampant corruption and troops who quit.

The trip had a strongly political flavor: Obama has been using the May 1, 2011, Bin Laden raid as a political cudgel to pummel Romney. A senior Obama aide, briefing reporters on condition that he not be named, said that the president had always intended to mark the anniversary with American troops. The aide also said that both Obama and Karzai had hoped to sign the partnership deal on Afghan soil.

Obama avoided any direct criticisms of Romney during the trip.

"I think them taking credit for the right decision is entirely appropriate. I think trying to attack me on that basis is disappointing and the wrong course," Romney said in an interview with "CBS This Morning."

"Of course the right course was to assassinate, execute Osama bin Laden and that is precisely what happened, and I congratulate the president for doing so. And I am confident and that of course I would have taken exactly the same decision," Romney said. "Any thinking American would have ordered exactly the same thing."

The Obama campaign released a brutal ad calling into question whether Romney would have ordered the raid. After Republicans complained that the president was overdoing it, Obama denied any "excessive celebration" and took a veiled shot at his all-but-certain rival.

More popular Yahoo! News stories:

What Robert Caro's LBJ biography 'The Passage of Power' could teach Obama and Romney

Why 2012 election predictions are rubbish: Fear the Black Swan!

Romney meets with Michael Bloomberg in hopes of landing endorsement

Want more of our best political stories? Visit The Ticket or connect with us on Facebook, follow uson Twitter, or add us on Tumblr. Handy with a camera? Join our Election 2012 Flickr group to submit your photos of the campaign in action.