Mr Obama criticised Republican Mr Romney's support for beginning the war in Iraq, declaring himself against plans to withdraw troops from Iraq, inconsistent stances on Afghanistan and for opposing nuclear treaties with Russia.
"Every time you've offered an opinion you've been wrong," Mr Obama said.
Mr Romney said that despite early hopes, the ousting of despotic regimes in Egypt, Libya and elsewhere over the past year had resulted in a "rising tide of chaos". He said the president had failed to come up with a coherent policy to grapple with change sweeping the Middle East.
The debate on foreign affairs came two weeks before election day as international issues took a higher profile in a dead-heat race that had up to now been dominated by economic issues.
Foreign policy is generally seen as Mr Obama's strength and in the debate he highlighted two of his campaign's main points: that he gave the order leading to the killing of terrorist leader Osama bin Laden and fulfilled a promise to withdraw US troops from Iraq.
Mr Romney, a former Massachusetts governor and wealthy businessman, has little foreign affairs experience, but has recently been on the offensive on international issues and has trimmed Mr Obama's advantage in foreign affairs.
In the debate, he said Mr Obama sent the wrong signal to Iranian leaders by going on an "apology tour" early in his presidency, while not visiting Israel. "We're four years closer to a nuclear Iran," he said.
Mr Obama, who called the "apology tour" comment the "biggest whopper" in the campaign, said he showed his strength in Iran by mobilising the world to support sanctions.
For the second week in a row Mr Obama went on the offensive from the opening moments of the debate as he continued to try to bounce back from a lacklustre performance in the first debate on October 3 which led to a rise in opinion polls for Mr Romney.
The debate performances have been judged at least as much by the general impressions of the candidates as by their specific proposals. With polls showing few voters ranking foreign affairs among their top concerns, the candidates were vying to leave the impression that they are strong leaders.
Mr Obama jabbed at Mr Romney's comments during the campaign that Russia was the United States' No 1 geopolitical foe.
"Governor, when it comes to our foreign policy, you seem to want to import the foreign policies of the 1980s, just like the social policies of the 1950s and the economic policies of the 1920s," Mr Obama said.
Both candidates underscored their support for Israel against a threat from Iran. "If Israel is attacked, we have their back," said Mr Romney - moments after Mr Obama vowed: "I will stand with Israel if Israel is attacked."
Both also said they opposed sending to US troops to Syria where opposition groups are fighting to topple President Bashar Assad's regime.
Mr Obama was seen as having the advantage going into the foreign policy debate at Lynn University in Boca Raton, Florida. But that also meant that expectations were higher for the president - a precarious position for a candidate in a tight race.
An NBC News/Wall Street Journal poll released on Sunday showed Mr Obama and Mr Romney tied, with both candidates backed by 47% of likely voters nationwide.
Both candidates were looking to energise their supporters in the final weeks of the campaign and win over a dwindling number of undecided voters in key states. The election is a state-by-state contest and the outcome in a small number of states that are not predictably Democratic or Republican will determine the winner.
To that end China has been the focus of much of the foreign policy discussion, with both candidates tying it to the loss of US manufacturing jobs - a big issue in Ohio, an important industrial state.
Mr Romney says Mr Obama has failed to stop China from stealing American intellectual property or from keeping its currency artificially low, hurting US businesses. He has pledged to declare Chinese a currency manipulator, which could lead to sanctions.
Mr Obama has highlighted actions he has taken against China before international trade bodies. He accuses Mr Romney of outsourcing US jobs to China when he ran the private equity firm Bain Capital.
But the biggest issue lately has been Libya. Republicans say the Obama administration did not provide enough security at the consulate in Benghazi and misled Americans by playing down the likelihood it was a terrorist attack. They say this reflects the failure of US policy in the Middle East.
So far, though, Libya has been a tough issue for Mr Romney. A statement he issued immediately after the attack, before the death of the ambassador was known, was seen as ill-timed and opportunistic.
And his attempt to confront Mr Obama on Libya in the second debate backfired when the moderator supported Mr Obama's claim that the president had called the killings an act of terror the day after the attacks. Mr Obama's heated rejoinder calling Mr Romney's comments offensive was one of the most widely-played excerpts from the debate.
Today's debate was moderated by veteran CBS newsman Bob Schieffer.
COMMENT RULES: Comments that are judged to be defamatory, abusive or in bad taste are not acceptable and contributors who consistently fall below certain criteria will be permanently blacklisted. The moderator will not enter into debate with individual contributors and the moderator’s decision is final. It is Belfast Telegraph policy to close comments on court cases, tribunals and active legal investigations. We may also close comments on articles which are being targeted for abuse. Problems with commenting? email@example.com