Updated

President Obama heralded the coming end of the decade-long Afghanistan war in a brief televised address to Americans on his surprise trip Tuesday to the country, where he signed a critical partnership agreement, visited U.S. troops and marked the one-year anniversary of Usama bin Laden's death.

"The goal that I set, to defeat Al Qaeda and deny it a chance to rebuild, is now within our reach," Obama declared from Bagram Air Base.

Obama used the address and the visit itself to preview America's exit from the war and offer assurances to both countries -- to America that the war will soon be over; to Afghanistan that its forces will be independent but not left dangling in the wind. "As you stand up, you will not stand alone," Obama said in a line directed at Afghans.

The president made sweeping statements about the course and eventual conclusion of both the Afghanistan and Iraq wars, insisting that America's role after 2014 will be limited. He said the U.S. will not build "permanent bases" in Afghanistan -- and has no intention of building "a country in America's image."

"We've 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," Obama said, praising America's troops and making a call to "renew America."

More On This...

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

The visit itself signaled the winding down of the war and effectively allows the president to claim in his re-election campaign that he shepherded the end of two wars. It also comes as Obama faces criticism for a recent campaign video that touted his decision to approve the bin Laden raid and questioned whether Mitt Romney would have done the same.

In a statement released by his campaign later, Romney said he was pleased that Obama had returned to Afghanistan, that the troops and the American people deserved to hear from the president what is at stake in the war. "Success in Afghanistan is vital to our nation's security," he said.

Obama mentioned bin Laden's death only in passing Tuesday, during a talk with troops and later during his address to the nation, noting that "one year ago, from a base here in Afghanistan, our troops launched the operation that killed Usama bin Laden."

Senior administration officials said Tuesday the president always planned to spend this "resonant" day with U.S. troops.

Obama did not discuss bin Laden as he signed the strategic partnership agreement on the U.S.-Afghan relationship beyond 2014. The president called it a "historic moment for our two nations."

"I'm here to affirm the bond between our two countries and to thank Americans and Afghans who have sacrificed so much over these last 10 years," Obama said during the signing ceremony. "Neither Americans nor the Afghan people asked for this war, yet for a decade we've stood together."

Obama then flew to Bagram Air Base to meet with troops before addressing the nation.

The partnership Obama signed Tuesday spells out the U.S. relationship with Afghanistan beyond 2014, covering security, economics and governance. The deal is limited in scope and essentially gives both sides political cover: Afghanistan is guaranteed its sovereignty and promised it won't be abandoned, while the U.S. gets to end its combat mission in the long and unpopular war but keep a foothold in the country.

The deal does not commit the United States to any specific troop presence or spending. But it does allow the U.S. to potentially keep troops in Afghanistan after the war ends for two specific purposes: continued training of Afghan forces and targeted operations against Al Qaeda. The terror group is present in neighboring Pakistan but has only a nominal presence inside Afghanistan.

Senior administration officials said the U.S. is seeking an enduring partnership and will not repeat the mistakes of the past by allowing the Taliban to rise and provide a safe haven for terrorists.

The Associated Press contributed to this report.