Kabul, Afghanistan (CNN) -- President Barack Obama marked the first anniversary of the death of terror mastermind Osama bin Laden with an unannounced visit to Afghanistan, signing a long-awaited strategic partnership agreement meant to set the conditions of an American withdrawal from the war-torn nation.
The president reiterated that U.S. forces will not remain "a single day longer" than necessary, that he remains committed to pulling 23,000 troops out of the country by September and that he will stick to a 2014 deadline to fully withdraw from Afghanistan.
"We will not build permanent bases in this country, nor will we be patrolling its cities and mountains," the president said during a nationally televised speech to the U.S. people from Bagram Air Base early on Wednesday (Tuesday evening in the United States). "That will be the job of the Afghan people."
An undetermined number of U.S. forces will remain in country past 2014 working as military advisers and counterterrorism forces, but officials have yet to decide for how long.
The trip comes as Obama's election campaign gears up and just weeks ahead of a NATO summit in Chicago, where the details of the transition and future commitments to the region are expected to be discussed.
Speaking to reporters from Turkey after the trip to Afghanistan, Senate Armed Services Committee Chairman Carl Levin, D-Michigan, and member Jack Reed, D-Rhode Island, pointed to a series of lightening-rod issues expected to be addressed at the summit.
They include hot topics such as Taliban and Haqqani safe havens in Pakistan, Afghan economic dependency on international spending and the grittier details of senior leadership positions within the nation's armed forces.
"One thing we're going to see if there can be an early retirement of the officer corps to make room for the younger class (of Pashtuns from the country's restive southern and eastern provinces)," said Levin, noting those groups are underrepresented.
"That's something that's going to be discussed in Chicago, a retirement incentive," he said, a subtle nod to lingering questions over the army's current legitimacy in traditional Taliban strongholds.
Going back to the Vietnam War era, American television networks have covered presidents speaking to military personnel or alongside foreign leaders overseas. But Obama's speech was the first televised address to the nation delivered from a war zone on foreign soil, according to White House spokesman Josh Earnest.
The president's trip was his third since taking office and comes amid heightened tensions between the Obama and Karzai governments after a string of incidents involving U.S. personnel.
Among them include an American service member charged with killing of 16 Afghan civilians, Quran burnings at a U.S. military base and the release of photographs of Americans posing with the remains of dead militants.
Meanwhile, two U.S. service members were killed and two were wounded in an explosion targeting their vehicle in Wardak province, officials said.
About two hours after Obama left the country, a powerful explosion rocked the capital. Authorities later reported that it was a suicide car bomb that detonated outside the gates of Green Village, a compound that houses contractors and aid workers.
The attack left at least seven people and wounded 17 others, including schoolchildren, officials said.
"This is another desperate attack by the Taliban," said NATO spokesman Gen. Carsten Jacobson. "Another attack by the insurgency that resulted in the deaths of innocent Afghan civilians, with most of that being children from a nearby school."
The U.N. Assistance Mission in Afghanistan said that the "indiscriminate and illegal attacks are unacceptable and that those responsible are fully accountable for the deaths and injuries of civilians."
In an e-mail, the Taliban denied there were civilian casualties and said it planned the attack after word circulated that the American president was going to be in Afghanistan, marking the start of their so-called spring offensive.
Obama also spoke of a "negotiated peace" and said his administration has been in direct talks with the Taliban. In March, the Afghan Taliban suspended the development of a diplomatic office in Qatar designed to allow them to hold talks with the United States, following public anger over the killing of the 16 civilians.
"We've made it clear that they can be a part of this future if they break with al Qaeda, renounce violence and abide by Afghan laws," Obama said Wednesday.
Addressing Afghan concerns that America will abandon the country once its troops leave, Obama noted, "With this agreement, I am confident that the Afghan people will understand that the United States will stand by them."
He later added that the U.S. "did not come here to claim resources or to claim territory. We came here with a very clear mission to destroy al Qaeda."
Karzai offered his thanks to the American people for helping Afghanistan, and the presidents shook hands after signing the Strategic Partnership Agreement in the atrium of the King's Residence, part of the Presidential Palace in Kabul.
"This agreement will close the season of the past 10 years and is going to open an equal relationship season," Karzai added. "With the signing of this agreement, we are starting a phase between two sovereign and independent countries that will be based on mutual respect, mutual commitments and mutual friendship."
The security risks in Afghanistan seemed particularly pronounced given the secretive nature and timing of the trip. Obama landed in Afghanistan in the cover of darkness, and the signing ceremony occurred in the early morning hours.
Presumptive GOP presidential nominee Mitt Romney said, "I am pleased that President Obama has returned to Afghanistan."
"Our troops and the American people deserve to hear from our president about what is at stake in this war," he said. "Success in Afghanistan is vital to our nation's security."
More than 130,000 troops from 50 countries serve in Afghanistan. The United States is the largest contributor, providing some 90,000 troops, followed by the United Kingdom (9,500), Germany (4,800) and France (3,600).
But war that began with widespread approval in 2001 is now increasingly unpopular in Europe and the United States. The latest CNN/ORC International poll in late March show 55% of respondents would like to see the U.S. remove all its forces before 2014.
More than 2,700 troops from the United States and its partners have died in the conflict. The majority of them American.
Last week, Afghan National Security Adviser Rangin Daftar Spanta and U.S. Ambassador Ryan Crocker initialed the text that outlined the kind of relationship the two countries want in the decade following the NATO withdrawal.
The deal had been long expected after Washington and Kabul found compromises over the thorny issues of "night raids" by U.S. forces on Afghan homes and the transfer of U.S. detainees to Afghan custody.
It seeks to create an enduring partnership that prevents the Taliban from waiting out a U.S. withdrawal to try to regain power, the senior administration officials have said.
CNN's David Ariosto, Tom Cohen, Barbara Starr, Keating Holland, Nick Paton Walsh and journalist Masoud Popalzai contributed to this report.