BOCA RATON, Florida (AFP) - Barack Obama pummeled Mitt Romney as “all over the map” on foreign policy, dismissing his “wrong and reckless” positions in the heated final debate of a knife-edge White House race.

With just two weeks until polling day, Obama has unexpectedly found himself running neck-and-neck with a challenger who had long trailed him, and Monday’s face-off on world affairs was perhaps a last chance to land a decisive blow.

“I know you haven’t been in a position to actually execute foreign policy, but every time you’ve offered an opinion, you’ve been wrong,” President Obama told his foe, coming out swinging in the debate in Boca Raton, Florida. Republican challenger Romney played it safe, avoiding any catastrophic error that would have undermined his bid to be commander-in-chief, but was often on the defensive, apart from when lambasting Obama over the struggling economy.

“Attacking me is not an agenda,” the former Massachusetts governor told the president, and renewed charges that Obama had mounted “apology tours” abroad, prompting the president to accuse him of telling a “whopper.” Obama had the best lines of the night and sharply cross-examined Romney on his approach to Syria, Iran and trade rows with China, accusing him of “airbrushing history” by dumping earlier hawkish conservative positions. The Republican, who has spent months attempting to paint Obama as a weak appeaser, actually backed much of the substance of the president’s global strategy, courting wavering voters ahead of the November 6 election. In a clear bid to moderate his image, Romney endorsed Obama’s decision to withdraw from Afghanistan in 2014, supported the president’s lethal drone war against terror suspects and congratulated him on hunting down Osama bin Laden.

Romney vowed to press China harder on trade and currency issues but toned down earlier rhetoric, following warnings his approach could spark a trade war. “We can be a partner with China. We don’t have to be an adversary in any way, shape or form,” he said, despite his vow to brand Beijing a currency manipulator on day one of his presidency. Oddly, neither candidate mentioned the eurozone crisis — widely seen as the country’s biggest external economic threat — aside from Romney reprising his warning that the debt-laden US economy under Obama was “heading toward Greece.”

An instant poll by CBS News found that Obama won the debate by 53 per cent to 23 per cent, after a clash that appeared to polish his leadership credentials and saw him showing the passion missing in his disastrous first debate. CNN’s poll found Obama beat Romney 48 to 40 per cent.

Barack Obama vowed Monday that Iran would not develop nuclear weapons so long as he is president and pledged full support to Israel, as he faced criticism from challenger Mitt Romney. “As long as I am president of the United States, Iran will not get a nuclear weapon,” Obama said in the third and final debate before November 6 presidential elections.