(CNN) -- Sens. John McCain and Barack Obama hammered away at each other's judgment on the economy, domestic policy and foreign affairs as they faced off in their second presidential debate.



Obama tried to tie McCain to President Bush's "failed" policies, while McCain pushed his image as a "consistent reformer" at the debate, which took place at Belmont University in Nashville, Tennessee.



The debate was set up as a town hall meeting, and the audience was made up of undecided voters.



Obama and McCain fielded questions from the crowd, Internet participants and moderator Tom Brokaw of NBC News.



The candidates spoke directly to each other at times, but at other times they spoke as if their opponent were not on the same stage, a few feet away. Debate report card



In comparison to the first debate, Tuesday's event -- which came on the heels of several days of increasingly aggressive attacks from both sides -- took on a more contentious tone.



On foreign policy, McCain charged that Obama "does not understand" the country's national security challenges.



McCain said he knows how to handle foreign affairs and questioned Obama's ability to do so.  Analysts weigh in on the debate »



"Sen. Obama was wrong about Iraq and the surge. He was wrong about Russia when they committed aggression against Georgia. And in his short career, he does not understand our national security challenges," McCain said. "We don't have time for on-the-job training, my friends."



McCain said the "challenge" facing a president considering using military force "is to know when to go in and when not."



"My judgment is something that I think I have a record to stand on," McCain said.  Video highlights of key moments »



Obama shot back and questioned McCain's judgment in supporting the invasion of Iraq.



"When Sen. McCain was cheerleading the president to go into Iraq, he suggested it was going to be quick and easy, we'd be greeted as liberators," he said. "That was the wrong judgment, and it's been costly to us."



The candidates spent about 30 minutes of the debate focusing on foreign affairs. They spoke about the economy for about 45 minutes and spent 15 minutes discussing domestic issues.  See scenes from the debate »



A national poll of debate watchers suggested that Obama won the presidential debate. Post-debate poll



Fifty-four percent of those questioned in a CNN/Opinion Research Corp. survey released 30 minutes after the end of the debate said that Obama did the best job, while 30 percent said McCain performed better.



The CNN/Opinion Research Corp. poll was conducted by telephone with 675 adult Americans who watched the debate. All interviews were taken after the end of the debate. The survey's sampling error is plus or minus 4 percentage points. iReport.com: Tell us who you think won round two



At the start of the debate, Obama said the country is in the worst financial crisis since the Great Depression.



He blamed President Bush and McCain for the crisis, saying they had worked to "strip away regulation." Bush: The elephant in the room



McCain said the system in Washington "cries out for bipartisanship" and pushed his record as a reformer.



He proposed having the government buy up and renegotiate bad home loans to stabilize the property market. He admitted the plan would be expensive but said it was necessary.  Watch McCain talk about his plan for the economy »



The Arizona senator also hammered away at his rival's tax policies, saying that "nailing down Sen. Obama's various tax proposals is like nailing Jell-O to the wall."  Watch McCain slam Obama's tax plan »



McCain charged that "Obama's secret that you don't know" is that he would increase taxes on small business revenue, which he said would lead to job cuts. Fact check: Did Obama vote 94 times for higher taxes



Obama shot back, saying "the Straight Talk Express lost a wheel on that one
What was the debate set up like? What did Obama and McCain discuss during half of the debate? Who is debating? What is the debate set up like? Who did Barack Obama try to tie John McCain to? What kind of image is McCain trying to make for himself? What was the audience comprised of? Who was in the audience? What does John McCain push? Who made up the audience of the debate?
as a town hall meeting, economy John McCain and Barack Obama as a town hall meeting, President Bush's "failed" policies, "consistent reformer" made up of undecided voters. undecided voters. his image as a "consistent reformer" undecided voters.
question: What was the debate set up like?, answer: as a town hall meeting, | question: What did Obama and McCain discuss during half of the debate?, answer: economy | question: Who is debating?, answer: John McCain and Barack Obama | question: What is the debate set up like?, answer: as a town hall meeting, | question: Who did Barack Obama try to tie John McCain to?, answer: President Bush's "failed" policies, | question: What kind of image is McCain trying to make for himself?, answer: "consistent reformer" | question: What was the audience comprised of?, answer: made up of undecided voters. | question: Who was in the audience?, answer: undecided voters. | question: What does John McCain push?, answer: his image as a "consistent reformer" | question: Who made up the audience of the debate?, answer: undecided voters.