Foreign policy is one of the key battlegrounds of the US presidential election, with Republican John McCain, a Vietnam veteran, casting himself as the better commander-in-chief, capable of dealing with international crises.
There is a clear difference between the two candidates' policies towards Iraq - one of the main foreign policy challenges facing the next US president, and in some other areas too.
John McCain was one of the most prominent supporters of the original decision to invade Iraq, and a key proponent of last year's "surge", when an extra 20,000 US troops were sent to the country.
He believes that combat troops should remain until Iraq has been stabilised, and the Iraqi government is able to maintain order itself. He has predicted that most troops would be home by 2013, but he is also in favour of a permanent US military presence in the country.
TRUSTED ON MIDDLE EAST
Americans with more trust in one candidate than the other to handle the situation involving -
Iraq: McCain 47%, Obama 45%
Iran: McCain 46%, Obama 44%
Israel and the Palestinians: McCain 44%, Obama 42%
Source: Washington Post/ABC News, 10-13 July
Opposition to the war in Iraq has been one of Barack Obama's signature campaign themes.
He strongly opposed the initial decision to send troops to Iraq, and has pledged to begin removing troops - at a rate of one battalion a month - as soon as he enters the White House, with a view to withdrawing all combat troops within 16 months.
But he says he would take advice from commanders on the ground about the best way to withdraw troops safely - and would retain a reduced presence after most of the troops have withdrawn, in order to enforce counter-terrorism measures against al-Qaeda.
He has also pledged to spend $2bn (£1bn) on government aid for Iraqi refugees, and called for a "diplomatic surge" to accompany the withdrawal of troops.
IRAQ WITHDRAWAL TIMETABLE
Americans preferring a timetable, or no timetable, for withdrawing US troops from Iraq
Prefer a timetable: 50%
Prefer no timetable: 49%
Source: Washington Post/ABC News, 10-13 July
Mr Obama agrees with Mr McCain that a nuclear Iran would represent a grave threat to US interests.
He would approach the issue by pursuing diplomatic options, including holding a meeting - without pre-conditions - with the Iranian President, Mahmoud Ahmadinejad. But he has also said he would do everything in his power to prevent Iran obtaining a nuclear weapon, and would keep the threat of military action on the table.
Mr McCain opposes any such meeting with the Iranian leader - he argues that holding talks without receiving any prior concessions would reward Iran for its behaviour.
The Arizona senator has been criticised for some of his statements on the campaign trail about Iran - in particular for an event at which he jokingly sang the words "Bomb Bomb Bomb Bomb Bomb Iran" to the tune of the Beach Boys' song "Barbara-Ann", and for his comment to a reporter - on being told that US exports of cigarettes to Iran were on the increase - that "maybe that's a way of killing them".
Both candidates believe in a two-state solution to the Arab-Israeli conflict, and both support a continuation of the strong alliance between Israel and the US.
Mr McCain has been keen to position himself as the most pro-Israeli candidate, and has described himself as "Hamas's worst nightmare".
But Mr Obama appeared to go even further than Mr McCain in the pro-Israeli direction, when he pledged his support for an "undivided" Jerusalem, which many observers interpreted as opposition to the idea of the Israelis and the Palestinians sharing the city.
He later clarified his position, saying that he had been guilty of "poor phrasing" and that he was not trying to "predetermine... final status issues".
Mr Obama has said Hamas is a "terrorist organisation" which has no place at the negotiating table - the conventional US position.
One of Mr Obama's principle objections to the war in Iraq was the fact that it reduced America's ability to go after al-Qaeda in Afghanistan.
He would use the military resources freed up by troop withdrawals in Iraq to commit more forces to Afghanistan. He also hopes that an increased US presence will encourage America's Nato allies to increase their military commitments there.
Mr McCain is committed to launching an Iraq-style surge in the country, with the deployment of as many as three extra brigades and the adoption of the kind of counter-insurgency tactics that Gen David Petraeus has been using in Iraq.
Mr Obama said in 2007 that he would launch attacks on al-Qaeda hideouts in Pakistan, with or without Pakistan's consent, if Pakistan did not act itself on intelligence about the presence of high-value terrorist targets. Mr McCain described the speech as "naive" and criticised the idea of "bombing an ally".
Both candidates have described the recent agreement between the US and North Korea over nuclear disarmament as "a step forward".
Mr Obama had advocated direct negotiations with the North Korean regime before this became part of the US strategy, while Mr McCain had accused Mr Obama of naivety for being prepared to meet North Korean leader Kim Jong-Il without preconditions.
Mr Obama has in turn attacked Mr McCain for his suggestion that China (and Russia - see below) should be excluded from the G8.
"Exclud[ing] them from the process of creating international rules of the road that are able to maintain order in the financial markets, that are able to address critical issues like terrorism, that are able to focus our attention on disparities of wealth between countries - that does not make sense," he told CNN's Fareed Zakaria.
But he has stressed his willingness to bring up human rights in negotiations with China's leaders, as has Mr McCain.
Mr McCain cites "hedg[ing] against potential threats from possible strategic competitors like... China" as a reason to invest in missile defence systems.
Both candidates have called on China to do more to isolate countries like Burma, Zimbabwe and Sudan.
John McCain paid tribute to America's European allies in a 26 March speech, calling on Americans to "welcome the rise of a strong, confident European Union as we continue to support a strong Nato".
He favours the development of a common energy policy, and - eventually - a common market.
Mr Obama has also lauded the US-EU alliance and has pledged to rebuild America's relationships with European countries, which he says have been damaged during the Bush administration's eight years in power.
He hopes that by ending the war in Iraq, and moving in step with Europe on the issue of climate change, relations will improve.
He would use this warmer relationship with European nations to persuade them to invest more troops in the war in Afghanistan.
Mr Obama has also stressed his support for EU enlargement, and his backing for Turkish membership of the EU.
And he has said he would invigorate and recalibrate the US's special relationship with the UK.
Mr McCain drew criticism from the Obama campaign for his 26 March speech in which he called on the G8 to exclude non-democracies, and warned of "the dangers posed by a revanchist Russia".
The threat from Russia, along with China, is cited by Mr McCain as a reason for investment in missile defence; Mr Obama has pledged to "fully consult Russia on prospects for mutually beneficial co-operation on missile defence but will not give Russia any veto over decisions about US national security".
He would also attempt to involve Russia in his efforts to crack down on nuclear proliferation and engage in negotiations to take US and Russian ballistic missiles off "hair trigger alert".
As a senator, Mr Obama led attempts to secure loose nuclear materials throughout the former Soviet Union.
With his African heritage, Mr Obama has made the continent a policy priority during his time in the Senate.
He spearheaded attempts to end the conflict in the Democratic Republic of the Congo, and pushed through a bill to fund efforts to bring former Liberian leader Charles Taylor to justice.
On Darfur, both candidates have signed a joint declaration calling for action.
Mr Obama is in favour of imposing tougher sanctions targeting Sudan's oil revenue, enforcing a no-fly zone, and deploying a large UN-led peacekeeping force to the region.
Mr McCain has pledged to establish a goal of eradicating malaria throughout the continent and has called for "strong engagement" with "friendly countries" across Africa.
For his part, Mr Obama favours increased development aid to the region, and would open a number of new US consulates throughout the continent.
Both candidates support tougher sanctions on Zimbabwe and would encourage its African neighbours to step in and force President Mugabe to hold fresh elections.
The two candidates' rhetoric on international trade could not be more different.
Mr McCain believes the US should "engage in multilateral, regional and bilateral efforts to reduce barriers to trade" worldwide and he wants the whole of North and South America to be a free-trade zone.
Mr Obama has been scathing about free trade on the campaign trail.
Both candidates have drawn up schemes to lower US emissions
He believes that the North American Free Trade Agreement (Nafta) was "oversold" to the American people and has pledged to work with the leaders of Canada and Mexico to "fix it" so that it "works for American workers".
The Illinois senator opposes the Central American Free Trade Agreement (Cafta) and would only promote trade agreements that "spread good labour and environmental standards around the world".
Foreign diplomats have expressed some concern about what they regard as protectionist rhetoric. However, since sewing up his party's nomination, Mr Obama has conceded that in relation to free trade his campaign rhetoric may have got "overheated and amplified".
On international efforts to combat climate change, both candidates are committed to working with other countries to reduce carbon emissions, and both have drawn up "cap and trade" schemes to bring down America's emissions.
Mr McCain is committed to negotiating a successor to the Kyoto treaty, and engaging China and Indian in the emissions reductions process.
Mr Obama has promised to establish a "Global Energy Forum", consisting of all the G8 members plus Brazil, China, India, Mexico and South Africa, and has pledged to re-engage with the UN Framework Convention on Climate Change.
Both appear to support President George W Bush's view that there can be no deal on a successor to Kyoto unless China and India are part of it.
Mr Obama has pledged to meet the Millennium Development Goal of cutting extreme poverty around the world in half by 2015, and would double America's foreign aid budget to $50bn (£25bn) to help achieve the goal.
John McCain visited Mexico and Colombia in early July.
During his visit, he emphasised his support for a trade deal between the US and Colombia, and reaffirmed his commitment to the North American Free Trade Agreement (Nafta), which lowers trade barriers between the US, Mexico and Canada.
In a speech he gave on 26 March, Mr McCain outlined his vision of North and South America as "the first completely democratic hemisphere, where trade is free across all borders, where the rule of law and the power of free markets advance the security and prosperity of all".
But Mr Obama has been critical of Nafta on the campaign trail, pledging to renegotiate the agreement, and has vowed not to support any deal - neither the renegotiated Nafta, nor the proposed agreement with Colombia - unless it guarantees a high level of protection for workers and the environment.
On Cuba, both candidates would maintain the current trade embargo, but Mr Obama would ease current restrictions on travel to the island, and would allow Cuban exiles to send money back to their relatives.
He has also indicated his willingness to meet Cuban leader Raul Castro (and another powerful anti-American figure in the region - the president of Venezuela, Hugo Chavez) for negotiations, without preconditions, a move that Mr McCain would not consider.
Both candidates support Plan Colombia - the aid package given by the US to Colombia to combat drug trafficking - and the Merida Initiative, a similar package aimed at the cross-border drugs trade between the US and Mexico.
On the campaign trail, Mr McCain has often argued that the free trade deals that he says bring economic improvements to Latin America will also reduce the flow of immigration into the US from south of the border.
But he wants to tighten up security on the border between Mexico and the US by strengthening the "physical and virtual" barriers on the frontier.
Mr Obama is less optimistic about the effect of free trade on Latin American economies, but agrees that economic development in this countries will reduce the incentives for immigration.
Both he and Mr McCain believe that - once they have arrived in the US - illegal immigrants should be given opportunities to pursue "pathways to citizenship".