Barack Obama laid the foundations for a new US foreign policy yesterday ahead of his trips to Europe and the Middle East, promising to work with allies to tackle the threats of the 21st century with a push comparable to the Marshall plan.

In his biggest speech on the matter since entering the presidential race in 2007, he said the US had "paid the price for a foreign policy that lectures without listening".

He set out five goals for his presidency: ending the war in Iraq; finishing the war with al-Qaida and the Taliban; ending US oil dependency; securing all nuclear weapons and materials from terrorists and rogue states; and rebuilding US alliances.

"As president, I will pursue a tough, smart and principled national security strategy - one that recognises that we have interests not just in Baghdad, but in Kandahar and Karachi, in Tokyo and London, in Beijing and Berlin," Obama told an audience at the Ronald Reagan building in the heart of Washington DC.

Just as he did earlier this year when speaking on race and patriotism, Obama spoke at length and in more detail than before. He has already built up a large team of foreign policy advisers. Obama, who is to visit Europe as well as Iraq and Afghanistan, said he wanted to work with European countries, an implicit criticism of the alienation of Germany and France in the early years of the Bush administration.

"It's time for America and Europe to renew our common commitment to face down the threats of the 21st century just as we did the challenges of the 20th," he said. The Marshall plan provided massive US investment to rebuild postwar Europe.

Obama envisaged Europe and other allies helping more in Afghanistan as well as in rebuilding Iraq. He praised Britain, France and Germany for their diplomatic efforts with Iran and said it was time for the US - which initially refused to participate - to play a full part in talks.

As part of his Marshall plan, he saw weak and vulnerable countries being strengthened and he promised to double US foreign assistance, to $50bn (£25bn) by 2012, with most of it going to Africa.

Obama confirmed his intention to switch military resources from Iraq to Afghanistan, saying one of his first steps would be to ask the military to find a way out of Iraq. He has said he intends to have all US combat troops out of Iraq within 16 months of becoming president.

A Washington Post poll yesterday showed 50% of US voters favour the setting of an exit timetable, while 49% back Republican rival John McCain's view that a timetable would be counterproductive.