HEMPSTEAD, N.Y. -- Faced with a tightening race, President Obama and Republican presidential nominee Mitt Romney engaged in one of the most hard hitting debates in recent memory Tuesday, often straying from the town hall debate format to attack each other and debate heatedly over energy, taxes and the economy.

An articulate and forceful Romney held his own, deflecting a newly energetic Obama, who attacked with the kind of aggression that was lacking in their first debate two weeks earlier.

"Obama was much better," Democratic strategist Doug Schoen told The Washington Examiner.

The two men, meeting in their second debate, went after each other from the first question, on energy, one of several put to the candidates by uncommitted voters gathered for the event at Hofstra University in New York.

Obama immediately accused Romney of flip-flopping in his support for the coal industry.

"When you were governor of Massachusetts, you stood in front of a coal plant and pointed at it and said, 'This plant kills,' and took great pride in shutting it down," Obama said. "And now suddenly you're a big champion of coal."

Romney shot back that Obama was preventing the nation from making the most of its natural resources.

"When the president ran for office, he said if you build a coal plant, you can go ahead, but you'll go bankrupt," Romney said.

Obama and Romney were jabbing at each other throughout the 90-minute session, addressing each other directly, stalking toward their opponent as they spoke, interrupting each other to charge that their positions were being misrepresented or that the rules of the debate were being violated.

Romney proved adept at highlighting the failures of Obama's first term, repeatedly pointing to soaring budget deficits, persistently high jobless numbers and the slow economic recovery as he tried to build rapport with voters who continue to hurt economically.

"The middle class is being crushed by the policies of a president who does not understand what it takes to get an economy going again." Romney said.

Obama repeatedly put Romney on the defensive, prompting Romney at one point to blurt out, "I'm still speaking."

Their exchanges grew particularly heated when Obama was asked why security at the U.S. consulate in Libya wasn't enhanced prior to the killing there of a U.S. ambassador and three others. Romney questioned why the White House kept insisting the attack was a spontaneous response to an anti-Muslim video when it was actually a planned terrorist attack by a group affiliated with al Qaeda. Obama accused Romney of exploiting a national security situation for political gain.

Obama, who was widely criticized within his own party for his laconic performance in the Oct. 3 debate, looked much sharper Tuesday, paying attention to Romney as he spoke, interrupting Romney whenever he had the chance. In a debate over how tough to get on China, Obama chided Romney for having a 401(k) retirement plan much bigger than his own, drawing a laugh from the studio audience.

Despite Obama's attacks, Boston College political science professor Marc Landy called the showdown a draw.

"Both are articulate and giving a good presentation of themselves," Landy said. "But I do think Romney is successfully getting the message across that in a wide variety of spheres -- gas price, jobs, deficit -- we are worse off than four years ago."