Bouncing back after being pilloried even by his own Democrats for appearing passive and listless during their first encounter in Denver, Obama was a different character on stage at New York's Hofstra University.
Instant surveys by CNN, which hosted the debate, and a host of other media organizations showed the more aggressive and combative Obama came out the clear winner against Romney, who spent more of the night on the back foot. Rebounding from the ropes after a dismal showing two weeks ago that sent his poll numbers tumbling, the president was aware a second poor outing could doom him to the historical ignominy of a single term.
Early signs were that Obama's passion-fueled performance will revive optimism among Democrats over his re-election bid even if Romney made a strongly-worded case that the president had presided over economic failure.
In one spellbinding exchange, Obama stared directly at Romney and rebuked him over his criticism of the White House's handling of an attack on the US consulate in Benghazi, Libya on September 11, 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," Obama said, wagging his finger at Romney across the stage of the town hall-style debate. Read: Key quotes from the second US presidential debate
"That's not what we do. That's not what I do as president, not what I do as commander-in-chief," Obama said, in the most memorable clash of one of the most ill-tempered and contentious White House debates ever.
Seeking to recover, Romney then seemed to stumble, accusing the president of taking days to call the attack, which killed US ambassador to Libya, Chris Stevens, terrorism.
Obama snapped back that he had referred to the assault as an "act of terror" a day after the attack, telling Romney: "check the transcript" before fixing his rival with a withering stare and saying "Please proceed governor."
CNN moderator Candy Crowley fact-checked on the spot in Obama's favor and the transcript of the president's Rose Garden remarks on September 12 confirmed that he did indeed imply the assault was terrorism.
US Republican presidential nominee Mitt Romney and US President Barack Obama speak directly to each other during the second US presidential debate in Hempstead, New York. Reuters photo
"No acts of terror will ever shake the resolve of this great nation," Obama said in the remarks, which contradict Republican claims he laid the blame fully on an anti-Muslim YouTube video made on US soil.
Even before the debate had ended, Democrats were seizing on the moment to question Romney's credentials to serve as commander-in-chief, while conservatives hammered Crowley for what they said was an unfair intervention.
As anger crackled in the debate hall, the candidates were freed from podiums and roamed the floor, often encroaching on each other's personal space.
Minutes into the clash, the two stood just a few feet apart, trading charge and counter-charge over economic policy. US down 'road to Greece': Romney
Romney's strongest moments came when he delivered stinging indictments of the Obama economy, charging the president with failing to rein in stubbornly high unemployment or cut ballooning deficits.
"The president wants to do well, I understand," Romney said, adopting a sorrowful tone of voice. "But the policies he put in place have not let this economy take off as it could have."
Obama slammed Romney over his attitude on women's issues, but the former Massachusetts governor and multi-millionaire businessman hit back over 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," he said, before also vowing to stand up to China over its alleged trade and currency abuses.
Obama countered that Romney had invested in companies in China that were pioneers of outsourcing US jobs, saying: "Governor, you're the last person who's going to get tough on China."
When Romney interrupted, asking Obama if his pension scheme included investment in low wage economies abroad, the president openly mocked his wealth. Obama- Romney bitter clash on tax-policy
"I don't look at my pension. It's not as big as yours."
Analysts gave Obama the edge but said the race was far from over.
"The Republicans will be disappointed that Romney didn't put him away, and the Democrats will be reassured that the president is in full press now," said Linda Fowler, a government professor at Dartmouth College.
Republican presidential candidate Mitt Romney speaks during the second presidential debate with US President Barack Obama at Hofstra University. AFP photo
John Pitney, professor of politics at Claremont McKenna College, said he thought "the president had a much better night than he had in Denver."
"It was close, but I have to give the edge to Obama."
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.
The two candidates were to return to key swing states on Wednesday, with Obama holding rallies in Iowa and Ohio and Romney heading to Virginia.
Romney, 65, took the first question of the night, about the jobs crisis, and bemoaned the plight of ordinary Americans who he said had been "crushed over the last four years."
"I know what it takes to create good jobs and to make sure you have the opportunity you deserve," Romney said. Obama takes the offense, says Romney just for rich
But Obama, 51, issued the parting shot of the night, blasting Romney comments -- which came to light last month in a secretly-taped video -- writing off 47 percent of American voters who don't pay income taxes as freeloaders who would vote for Obama in order to keep their government handouts.
"When he said behind closed doors that 47% of the country considered themselves victims who refuse personal responsibility, think about who he was talking about," Obama said, pointing out that this included war veterans, students and soldiers serving in war zones.
"I want to fight for them," he said. "That's what I've been doing for the last four years. Because if they succeed, I believe the country succeeds."
Obama accepted Benghazi responsibility
President Obama assumed responsibility over the deadly terror attack in Libya in September that killed four Americans just hours after secretary of state Hillary Rodham Clinton sought to shoulder the blame for any mistakes the administration made.
"She works for me," the president said. "I'm the president and I'm always responsible, and that's why nobody's more interested in finding out exactly what happened than I do."
A debate booklet is held up after the second presidential debate between President Barack Obama and Republican presidential nominee Mitt Romney at Hofstra University. AP photo
With three weeks before the presidential election, the administration has been unable to put to rest its handling of the Benghazi attack that killed ambassador Chris Stevens, a state department computer specialist and two former Navy SEALs who were working as contract security guards.
Obama's statement came amid a spirited back-and-forth with the former Massachusetts governor over the assault on the consulate, the only significant foreign policy disagreement in an hour-and-a-half exchange dominated by domestic concerns.
The two also traded jabs on how quickly the president declared Benghazi an act of terror with Romney insisting it took two weeks and Obama saying he said as much the day after in an address from the White House Rose Garden. That drew an intervention from the moderator, CNN's Candy Crowley, who appeared to side with Obama.
Obama, Romney clash on illegal immigration
Both the candidates clashed over illegal immigration in their testy second debate with Romney accusing Obama of failing to come up with an immigration reform bill as he had promised before assuming office in 2009.
"When the president ran for office, he said that he would put in place in his first year a piece of legislation, file a bill in his first year, that would reform our immigration system, protect legal immigration, stop illegal immigration. He didn't do it," Romney charged.
Obama fired back by saying he had in fact tried to push through reform but ran into Republican opposition in Congress.
"That's not true. I sat down with Democrats and Republicans at the beginning of my term, and said: 'Let's fix this system, including Republicans previously on the other side," Obama said.
Read: Full text of the second US presidential debate