Obama was much sharper and more energetic than in their opening debate two weeks ago when his listless performance was heavily criticised and gave Romney's campaign a much-needed boost in the run-up to the November 6 election.
The president scolded Romney for accusing him of trying to take political advantage of the attack by extremists in Libya last month that killed four Americans, including the US ambassador Chris Stevens.
"That's not what we do. That's not what I do as president, that's not what I do as commander-in-chief," Obama said during the debate at Hofstra University in Hempstead, New York, calling the accusation "offensive."
"I'm the president and I'm always responsible and that's why nobody's more interested in finding out exactly what happened," Obama said.
Romney questioned Obama's claim that he called the Benghazi attack "an act of terror" in the White House Rose Garden the day afterward, but moderator Candy Crowley of CNN corrected the Republican. Transcripts show Obama did use the term that day.
Failing to follow through
The Republican accused Obama of failing to follow through on the promises of his 2008 campaign.
In one of his stronger moments in the 90-minute debate, Romney took aim at Obama's economic record in office, saying it has led to 15-million more people on food stamps, slow growth and a lack of jobs.
"The middle class is getting crushed under the policies of a president who has not understood what it takes to get the economy working again. He keeps saying, 'Look, I've created 5-million jobs.' That's after losing 5-million jobs. The entire record is such that the unemployment has not been reduced in this country," the former Massachusetts governor said.
Polls showed voters judged Obama the winner. A CNN survey gave him the edge by 46% to 39% while CBS had Obama the winner by 37% to 30%.
"I think Obama won this one. I'll say I'm a Romney supporter but I don't think he effectively got all his points," said audience member James Digirolamo, from Long Island, New York.
"I was a little disappointed how the moderator handled the debate, in particular the issue with the 'terror' remark," he said, referring to criticism by Republicans that moderator Crowley intervened in favour of Obama during the exchange over Libya.
Both candidates roamed the stage to talk directly to participants in the town-hall format, where undecided voters from Long Island asked the questions.
At times the two men circled each other warily at centre stage like prize fighters, talking over each other and bickering frequently about the rules and who had exceeded their time.
Romney confronted Obama face-to-face at one point to ask repeatedly if licenses and permits for energy drilling on federal land had been reduced during his administration.
Recent polls have put the race for the White House at a virtual dead heat just three weeks ahead of the election.
Obama seems to have stopped his slide after the last debate. In a Reuters/Ipsos daily tracking poll on Tuesday, he gained a bit more ground on Romney for the third straight day and led 46% to 43%.
But a Gallup/USA Today survey showed Romney ahead by 4 percentage points in the 12 most contested states.
After being slammed for his passive performance in the first debate, Obama attacked Romney repeatedly this time.
He resurrected his charge that the economic proposals put forward by the former private equity executive were designed to protect and bolster the wealthy at the expense of the middle class.
Set of rules
"Governor Romney says he's got a five-point plan. Governor Romney doesn't have a five-point plan, he has a one-point plan. And that plan is to make sure that folks at the top play by a different set of rules," Obama said.
Romney said Obama's economic record speaks for itself.
"The president has tried but his policies haven't worked. He's great as a speaker and at describing his plans and his vision. That's wonderful, except we have a record to look at and that record shows that he just hasn't been able to cut the deficit, to put in place reforms for Medicare and Social Security to preserve them, to get us the rising incomes we need."
Arguing that he supports equal opportunities for women, Romney said he once had "binders full of women" candidates for Cabinet jobs when he was Massachusetts governor. The quote suggested that influential women were not part of Romney's circle and prompted a flurry of comments on social media.
The two also clashed over the Obama administration's 2009 auto bailout, with Romney saying Obama had misrepresented his position that General Motors should go into a managed bankruptcy.
"He keeps saying, you want to take Detroit bankrupt. Well, the president took Detroit bankrupt," Romney said. "You took General Motors bankrupt. You took Chrysler bankrupt. So when you say that I wanted to take the auto industry bankrupt, you actually did."
Obama responded: "What Governor Romney said just isn't true. He wanted to take them into bankruptcy without providing them any way to stay open. And we would have lost a million jobs."
The pair meet again next week in Boca Raton, Florida for their final debate, which will be on foreign policy. – Reuters