He was speaking after the US lost nine soldiers at the weekend in the deadliest attack on its forces in the country since 2005.
Obama has promised, soon after becoming president in January, to begin scaling back the 156,000 US troops in Iraq and Kuwait, and to shift the focus to Afghanistan.
He is to fill out his plans in a foreign policy speech in Washington today ahead of his first visit to Iraq and Afghanistan since he launched his presidential bid early last year.
Ewen MacAskill on Obama's foreign policy Details of his trip have been kept secret for security reasons but a senior Palestinian spokesman, Saeb Erekat, disclosed yesterday that Obama would be in the region next week, with a meeting in the West Bank on July 23 with the Palestinian president, Mahmoud Abbas.
Bill Burton, a spokesman for Obama, said today's speech "will focus on the global strategic interests of the United States, which includes ending our misguided effort in Iraq". He added that a gradual, phased withdrawal of US troops "will allow the US to properly address the growing threat from a resurgent al-Qaida in Afghanistan".
Previewing the speech in an article written for the comment page of the New York Times yesterday, Obama wrote: "As president, I would pursue a new strategy and begin by providing at least two additional combat brigades to support our effort in Afghanistan. We need more troops, more helicopters, better intelligence-gathering and more non-military assistance to accomplish our mission there."
He said that ending the war in Iraq is "essential to meeting our broader strategic goals, starting in Afghanistan and Pakistan, where the Taliban is resurgent and al-Qaida has a safe haven".
In a separate comment on the campaign trail, Obama said the killings on Sunday reinforced the need to switch resources from Iraq to Afghanistan.
"I continue to believe that we're under-resourced in Afghanistan," he said. "That is the real centre for terrorist activity that we have to deal with and deal with aggressively."
As well as visiting Iraq and Afghanistan, he is to go to Germany, France and Britain and call on Germany and France, in particular, to increase their involvement in Afghanistan.
His Republican rival, John McCain, is also to discuss Afghanistan this week. Randy Scheunemann, a senior McCain foreign policy adviser, noted yesterday that Obama had voted in the senate last year against increased resources for US troops in Afghanistan.
"Senator Obama is not trying to have it both ways, he's trying to have it every way," Scheunemann said.
Although eclipsed by the US's economic slide as the main election issue, the war in Iraq remains one of the clearest points of division between Obama and McCain, who is committed to remaining in the country until stability is achieved.
Obama, in the New York Times article, reiterated his promise to have all US combat troops out by the summer of 2010, with a "residual" force left in place to fight al-Qaida and train Iraqi forces.
© Guardian News and Media Limited 2008