Vowing to shift the "single-minded" US focus from Iraq to al-Qaeda strongholds in Pakistan and Afghanistan, Obama said the war in Iraq "distracts us from every threat that we face and so many opportunities we could seize".
"If another attack on our homeland comes, it will likely come from the same region where 9/11 was planned. And yet today, we have five times more troops in Iraq than Afghanistan," he said, criticising both George Bush, the US president, and McCain, his Republican opponent, over their Iraq strategies.
McCain, however, said that early troop withdrawals from Iraq would squander the success of last year's troop surge strategy and could lead to chaos in the fragile country.
Obama "has it exactly backwards," McCain said.
In a speech delivered at Albuquerque, New Mexico, McCain said the troop increase strategies used in Iraq should also be applied to Afghanistan and that he knows more than Obama about "how to win wars".
McCain said:"When I'm commander-in-chief, there will be nowhere terrorists can
run and hide".