US President Barack Obama launched aggressive attacks against Republican rival Mitt Romney on jobs, energy and Libya in their second debate.
Mr Obama was sharper and more energetic than in their opening debate two weeks ago, when his listless performance was heavily criticised and gave Mr Romney's campaign a much-needed boost.
The president took issue with Mr Romney for accusing him of trying to take political advantage of the attack by Islamist militants in Libya last month.
Four Americans, including the US Ambassador Chris Stevens, were killed in the attack.
"That's not what we do. That's not what I do as President, that's not what I do as commander in chief," Mr Obama said during the debate at Hofstra University in Hempstead, New York.
He described the accusation as "offensive".
"I'm the President and I'm always responsible, and that's why nobody's more interested in finding out exactly what happened," Mr Obama said.
Mr Romney questioned Mr Obama's claim that he called the Benghazi attack "an act of terror" in the White House Rose Garden the following day, but moderator Candy Crowley corrected the Republican.
Transcripts show Mr Obama did use the term that day.
Mr Romney also accused Mr Obama of failing to follow through on the promises of his 2008 campaign.
He took aim at Mr Obama's economic record in office, saying it has led to 15m more people on food stamps, slow growth and a lack of jobs.
The former Massachusetts governor said: "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 5m jobs'. That's after losing 5m jobs. The entire record is such that the unemployment has not been reduced in this country."
Polls showed voters judged Mr Obama the winner.
A CNN survey gave him the edge by 46% to 39%, while CBS had Mr Obama the winner by 37% to 30%.
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, talking over each other and bickering frequently about the rules and who had exceeded their time.
Mr Romney confronted Mr Obama face-to-face at one point to ask repeatedly if licences and permits for energy drilling on federal land had been reduced during his administration.
Obama halts slide in opinion polls
Recent polls have put the race for the White House at a virtual dead heat just three weeks ahead of the election.
Mr Obama seems to have stopped his slide after the last debate.
In a Reuters/Ipsos daily tracking poll yesterday, he gained some more ground on Mr Romney for the third straight day and led 46% to 43%.
But a Gallup/USA Today survey showed Mr Romney ahead by 4% in the 12 most contested states.
After being slammed for his passive performance in the first debate, Mr Obama attacked Mr 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.
Mr Obama said: "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."
Mr Romney said Mr Obama's economic record speaks for itself.
He said: "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, Mr 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 Mr 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 Mr Romney saying Mr 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," Mr 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."
Mr 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.