
Public opinion polls have shown Obama making gains over the past week on the question of who could best lead the country on economic issues, and most polls have Obama holding a slight and growing lead over McCain.
When the debate turned to foreign policy, Obama criticized McCain's judgment in supporting the US military invasion of Iraq. McCain has been one of the most staunch advocates of the war.
"The first question is whether we should have gone into this war in the first place," said Obama, an Illinois senator who opposed the war from the beginning.
McCain said the big question facing the next president will be "how we leave and when we leave." He said Obama had shown poor judgment by opposing the surge policy that sent more troops to Iraq and has been credited with reducing violence there.
McCain also attacked Obama for his willingness to talk with leaders of hostile nations like Iran without preconditions, but Obama pointed out that Henry Kissinger, the former secretary of state who is one of McCain's foreign policy advisers, supported the same approach.
The two candidates also clashed on Pakistan, with Obama saying the United States should attack militants in Pakistan if Islamabad was unwilling to do so. McCain said he would not back such a policy.