However the BBC's Ian Pannell in Kabul says there is concern that putting a date on a US withdrawal sends the wrong signal and risks giving encouragement to the Taliban.
In his speech, Mr Obama:
celebrated the US as a nation "founded in resistance to oppression" and talked about its long record of sacrifice in "advancing frontiers of human liberty"
promised an "effective partnership" with Pakistan, and warned that the US could not "tolerate a safe haven for terrorists "
repeatedly cited the poor economy and stated that the estimated cost - $30bn for the US military this year - was a factor in his deliberations
The speech was delivered at the West Point military academy in New York.
Adam Brookes, BBC News, Washington
There seems to be an acknowledgement that a level of insurgent activity will continue - even in the best case scenario. Wiping out the Taliban is not a war aim. And given the Taliban's ability to make use of parts of Pakistan as a safe haven, nor could it be.
The July 2011 date requires that, by then, elements of the Afghan armed forces are in sufficiently good shape to begin taking on sole responsibility for security. The first areas of the country handed over would be those that are quietest and least vulnerable to Taliban influence.
This is a very rapid timetable - accelerated, the president called it - and there will be many in the US military who wonder if it is optimistic, given the difficulties of finding competent leaders for the Afghan army and police.
Stressing that the US was in Afghanistan because of the 9/11 attacks on America by al-Qaeda militants, Mr Obama said their Taliban allies had "begun to take control over swathes of Afghanistan" while committing "devastating acts of terrorism" against Pakistan.
US forces, he said, lacked "the full support they need to effectively train and partner with Afghan security forces and better secure the population".
"I have determined that it is in our vital national interest to send an additional 30,000 US troops to Afghanistan," he told the cadets.
"After 18 months, our troops will begin to come home."
Rising violence - more than 900 US soldiers have died in Afghanistan - and August's discredited elections have fanned mounting domestic opposition to the eight-year-old war.
Mr Obama said he was aware of the gravity of his decision to send the extra troops but he urged Americans not to see the conflict as a new Vietnam war.
America was backed by a "broad coalition of 43 nations", he said, and was not facing a "broad-based popular insurgency".
"Most importantly, unlike Vietnam, the American people were viciously attacked from Afghanistan, and remain a target for those same extremists who are plotting along its border," the US leader added.
TROOPS FIGHTING THE TALIBAN
US: More than 100,000 by July 2010
Other foreign (mainly Nato): Some 32,000 currently, with a British offer of 500 more
The US would take the Iraq experience as its model for withdrawal, he added.
"Just as we have done in Iraq, we will execute this transition responsibly, taking into account conditions on the ground," he said.
Pledging to continue to advise and assist Afghanistan's security forces, he warned: "It will be clear to the Afghan government - and, more importantly, to the Afghan people - that they will ultimately be responsible for their own country.
"The days of providing a blank cheque are over," he added.
Other priorities Mr Obama outlined included enhancing US domestic security, preventing nuclear materials falling into the hands of terrorists and forging better ties with the Muslim world.
Plea to allies
The White House wants to convey that this is Barack Obama's war and he is clear about the aims he wants to achieve, the BBC's Matthew Price says.
Calling on America's allies to boost their troop commitment, Mr Obama said: "What's at stake is the security of our allies, and the common security of the world."
From my perspective as a Nam Vet 67/68, it appears to be Deja Vu
Welcoming the US pledge, UK Prime Minister Gordon Brown said: "I call on all our allies to unite behind President Obama's strategy.
"Britain will continue to play its full part in persuading other countries to offer troops to the Afghanistan campaign," Mr Brown said, a day after London confirmed it was sending 500 more troops, taking the UK's total deployment to 10,000.
French President Nicolas Sarkozy offered full support to Mr Obama's strategy and called it "courageous" but France earlier ruled out deploying more combat soldiers, though it might send military trainers.
Germany has said it will wait until after a 28 January conference in London on Afghanistan before deciding on any troop increases.
Italy has also said it will increase its force, although without saying by how much.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.