KABUL, Afghanistan (CNN) - President Barack Obama marked the first anniversary of the death of terror mastermind Osama bin Laden with an unannounced trip to Afghanistan, where he reiterated that U.S. troops will not remain in the country "a single day longer" than necessary.
Obama said he remains committed to pulling 23,000 troops out of the country by the end of summer and sticking to the 2014 deadline to turn security fully over to the Afghan government. He said that NATO will set a goal this month for Afghan forces to be in the lead for combat operations next year.
"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 at Bagram Air Base early Wednesday. "That will be the job of the Afghan people."
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, White House spokesman Josh Earnest said.
Obama's trip was his third to Afghanistan since taking office and comes as he fights for re-election. The president is scheduled to return to Washington around noon Wednesday.
Meanwhile, two coalition service members were killed and two wounded in an explosion targeting their vehicle in Wardak province, Maj. Paul Haverstick said. A U.S. official told CNN the victims were Americans.
And about two hours after Obama left the country, a powerful explosion rocked the capital, Kabul, authorities reported.
A suicide car bomb was detonated outside the gates of Green Village, a compound that houses contractors and aid workers, killing at least seven people and wounding 17 others, the Afghan Interior Ministry said. The casualties included schoolchildren.
"This is another desperate attack by the Taliban," said Gen. Carsten Jacobson, a spokesman for the NATO-led International Security Assistance Force. "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 any civilian casualties and said it planned the attack after word circulated that the American president was going to be in Afghanistan. The group also said it will launch its spring offensive Thursday.
In his speech, even as Obama pledged to not keep troops in harm's way "a single day longer than is absolutely required for our national security," he promised to "finish the job" and "end this war responsibly."
Obama also spoke of a "negotiated peace" and said his administration has been in direct talks with the Taliban. "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," he said.
Finally, the president vowed: "This time of war began in Afghanistan, and this is where it will end."
Earlier in his trip, Obama and Afghan President Hamid Karzai signed an agreement outlining cooperation between their countries once the U.S.-led international force withdraws in 2014.
Some U.S. forces will remain in a post-war Afghanistan as military advisers, but both U.S. and Afghan officials have yet to decide how many troops will continue supporting the Afghan military, and for how long.
At a signing ceremony for the Strategic Partnership Agreement, Obama said that neither country asked for the war that began more than a decade ago, but now they would work in partnership for a peaceful future.
"There will be difficult days ahead, but as we move forward in our transition, I'm confident that Afghan forces will grow stronger; the Afghan people will take control of their future," Obama said.
Addressing a concern in Afghanistan that the United States will abandon the country once its troops leave, Obama said, "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 United States "did not come here to claim resources or to claim territory. We came here with a very clear mission to destroy al Qaeda," referring to the terrorist organization responsible for the September 11, 2001, attacks.
Obama's address came nine years to the day after then-President George W. Bush delivered his "Mission Accomplished" speech aboard the aircraft carrier USS Abraham Lincoln, announcing the end of major combat operations in Iraq.
Karzai offered his thanks to the American people for helping Afghanistan, and the presidents shook hands after signing the document 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