Media playback is unsupported on your device Media caption Romney accuses Obama of 'apology tour'

US President Barack Obama has forcefully attacked his Republican challenger Mitt Romney, in their third and final presidential debate.

During the tense encounter in Florida, the rivals tangled over the Arab Spring, Iran, Israel and China.

Mr Obama said his rival was "all over the map" on foreign policy. But Mr Romney said the president had allowed "chaos" to engulf the Middle East.

Two instant polls said Mr Obama won the head to head.

The Democratic president went on the attack from the start of Monday night's forum, trying to trip up his rival.

'Rising tide of chaos'

But Mr Obama did not appear to land any knockout blows on Mr Romney, who has been gathering momentum with two weeks to go until election day, in a race that is now neck and neck.

Our experts' analysis Mark Mardell, BBC North America editor - Barack Obama had the best lines, but perhaps Mitt Romney had the best night. Not in the sense that he won the debate - it was a draw if you have to judge these things that way. This final debate probably won't shift the opinion polls, but it saw a marked change in emphasis in Mr Romney's foreign policy ... Read more from Mark

- ... Read more from Mark Kim Ghattas, BBC's US state department correspondent - Romney agreed often with the president, made sure he did not sound like he was going to take America into another war. He criticised the president by attacking him from the left a few times. Maybe that could sway some undecided voters who prefer Republican economic policies but were worried about electing a warmonger. How Kim tweeted the debate

- How Kim tweeted the debate Jonathan Marcus, BBC's defence and diplomatic correspondent - For all the apparent divisions on the campaign trail, this final debate was about proving statesmanship and a capacity to lead and to keep America safe... Read more from Jonathan

The debate at Lynn University in Boca Raton, moderated by veteran CBS News presenter Bob Schieffer, was not as fractious as their second encounter last week, when Mr Obama came out fighting after his lethargic performance in their first meeting.

But there were several scathing exchanges, with the president seeking to portray his challenger as a foreign policy novice lacking the consistency to be commander-in-chief.

Mr Obama said the former Massachusetts governor had backed a continued troop presence in Iraq, opposed nuclear treaties with Russia and flip-flopped over when the US should leave Afghanistan.

"What we need to do with respect to the Middle East is strong, steady leadership, not wrong and reckless leadership that is all over the map," said Mr Obama.

But Mr Romney charged that the president had allowed a "rising tide of chaos" to sweep the Middle East, giving al-Qaeda the chance to take advantage.

"I congratulate him on taking out Osama Bin Laden and taking on the leadership of al-Qaeda," said Mr Romney, "but we can't kill our way out of this. We must have a comprehensive strategy."

Mr Obama hit back sarcastically that he was glad Mr Romney had recognised the threat posed by al-Qaeda, reminding him that he had previously cast Russia as the number one geopolitical foe of the US.

"I know you haven't been in a position to actually execute foreign policy," said Mr Obama, "but every time you've offered an opinion you've been wrong."

Mr Romney, who kept a measured tone during the debate, described a trip by President Obama to the Middle East as an "apology tour" that had projected American "weakness" to enemies, while bypassing close ally Israel. Mr Obama called that claim the "biggest whopper" of the campaign.

The Republican also said: "We're four years closer to a nuclear Iran", although he softened the uncompromising tone that has been the hallmark of his campaign by emphasising that military action should be a last resort.

'Fewer horses and bayonets'

Mr Romney barely touched on last month's deadly assault on the US consulate. His line of attack on that subject was widely perceived to have misfired in the last debate.

The rivals also found plenty to agree on - declaring unequivocal support for Israel, voicing opposition to US military intervention in Syria, and insisting that China play by trade rules.

Mr Romney even backed the president's policy of withdrawing from Afghanistan by 2014 - something the Republican has previously disagreed with.

In one of the most biting exchanges, Mr Obama mocked Mr Romney's complaint that the US had fewer ships now than it did during World War I.

"You mentioned the Navy, for example," said Mr Obama, "and that we have fewer ships than we did in 1916. Well, governor, we also have fewer horses and bayonets than we did in 1916."

Although the debate was meant to focus on foreign policy, the two candidates repeatedly pivoted back to the fragile US economy, an issue uppermost in American voters' minds.

A CBS News snap poll declared 53% believed Mr Obama won, versus 23% for Mr Romney and 24% saying it was a draw. A CNN poll put Mr Obama as the winner by 48% to 40%.

An NBC poll the day before the debate had put the men in a dead heat, each with 47% support.

Their last meeting behind them, both men have now launched a final two weeks of campaigning in swing states.

Already four million ballots have been cast in early voting in more than two dozen states.