US president Barack Obama has gone on the attack against Republican candidate Mitt Romney in their second debate three weeks from election day.

Seeking to recover ground lost following a poor performance in the first debate, Mr Obama was much more energetic and specific in defending his economic record and more aggressive in confronting his opponent.

He bounced off the ropes knowing his tumbling poll numbers could doom him to the historical ignominy of a single term without a sharp intervention.

Early signs were that Mr Obama's passion-fuelled performance will revive optimism and enthusiasm among Democrats in his bid for a second term, though Mr Romney, touting entrepreneurship, scored blows of his own on the economy.

In one spellbinding exchange, the president stared directly at Romney and rebuked him over his criticism of his White House for its handling of an attack on the US consulate in Benghazi which killed four Americans.

"The suggestion that anybody on my team, whether it's a secretary of state, our UN ambassador, anybody on my team, would play politics or mislead when we've lost four of our own, governor, is offensive," Mr Obama said wagging his finger at Mr Romney across the stage of their town-hall debate.

"That's not what we do. That's not what I do as president, not what I do as commander-in-chief," the president added, in a fiery moment in one of the most ill-tempered and contentious debates ever.

Seeking to recover, Mr Romney then seemed to stumble, accusing the president of taking days to call the attack a "terror attack".

But Mr Obama snapped back that he had indeed referred to the assault as "an act of terror", telling Mr Romney "check the transcript" before moments later fixing his rival with a withering stare and saying: "Please proceed governor."

CNN moderator Candy Crowley confirmed that Mr Obama did in fact use the phrase "act of terror" in the White House Rose Garden the day after the attack.

The exact quote confirms that Mr Obama did imply the assault was an act of terror despite Republican claims he laid the blame fully on an anti-Muslim YouTube video made on US soil.

"No acts of terror will ever shake the resolve of this great nation," Mr Obama said in the remarks on September 12.

Democrats seized on the moment to question Mr Romney's credentials to serve as commander-in-chief even before the debate ended, while conservatives were hammering Crowley for what they said was an unfair intervention.

Slanging match

As anger crackled in the debate hall, the candidates were freed from podiums at Hofstra University, New York, and roamed the floor, often encroaching on each other's personal space.

Minutes into the clash, Republican Romney and Democrat Obama stood just a few feet apart, trading charge and counter charge in a furious verbal slanging match over economic policy.

In another heated exchange over energy, Mr Romney triggered an audible gasp of shock in the hall hosting the debate, when he told the president: "You'll get your chance in a moment, I'm still speaking."

"Not true, governor Romney, not true," Mr Obama said, after the Republican savaged the president's record on oil production over the past four years.

Mr Romney's strongest moments came when he delivered stinging indictments of the Obama economy, charging the president with miserably failing to restore speedy jobs growth and to cut ballooning deficits.

"The president wants to do well, I understand," Mr Romney said, in a sorrowful tone of voice.

"But the policies he put in place have not let this economy take off as it could have."

Mr Romney also furiously accused the president over debt.

"We've gone from $10 trillion of national debt to $16 trillion of national debt.

"If the president were re-elected, we'd go to almost $20 trillion of national debt. This puts us on a road to Greece," before also vowing to stand up to China over what he says are trade and currency abuses.

Mr Obama hit back that Mr Romney had invested in companies in China that were pioneers of outsourcing US jobs.

"Governor, you're the last person who's going to get tough on China."

When Mr Romney tried to counter-attack, asking Mr Obama if his pension scheme included investment in low-wage economies abroad, the president openly mocked him.

"I don't look at my pension. It's not as big as yours. I don't check it that often."

'Primal' politics

One commentator called this contest politics "at its most primal", saying he had never seen a debate "where the personal animus and near-physical confrontation was so clear".

Despite a sturdy performance from Mr Romney, the immediate headlines were in Mr Obama's favour.

"He did today what he avoided doing, what he failed to do during the first debate, namely go on the offensive, go ahead and respond. He came out swinging from the beginning and he didn't stop," one reporter said.

"This was probably, I think, the best debate of Barack Obama's career as a national politician," said another.

But some observers, like Republican strategist Steve Schmidt, had a more nuanced take.

"I think when Mitt Romney says 'we don't have to settle' the president said he would but he didn't. Implicit in all of the Romney attacks is that things are going to be better when I, Mitt Romney, am president," he said.

"Now I think the president is lacking a clear second term agenda that he is articulating. He is forced into a position where he is defending the status quo."

Mr Obama broke into a broad smile as the debate ended. The question now is whether the president's showing will be strong enough to arrest Mitt Romney's momentum in the polls.

Just 21 days before the election, the obvious antipathy between the candidates reflected stakes that could hardly be higher as national polls and the race in battleground states tightens into a dead heat.