Obama said, "Spain is a NATO ally!" in apparent outrage. "If we can't meet with our friends, I don't know how we're going to lead the world in terms of dealing with critical issues like terrorism."
McCain seemed prepared for the line, saying, "I'm not going to set the White House visitors schedule before I'm president of the United States. I don't even have a seal yet," tweaking a much-mocked seal that the Obama campaign had on the candidate's podium during a speech early in the campaign season.
Earlier, Obama had knocked McCain's claim that a statement by Obama on Pakistan showed the younger man's inexperience on foreign policy.
Obama said McCain was right to point out presidents need to be careful about what they say, but noted McCain has threatened extinction for North Korea and sung a flip song about bombing Iran.
McCain then cited what he considered his sage foreign policy calls against putting ill-fated Marines in Beirut in the 1980s, and on the first Gulf War, Kosovo, Somalia and other conflicts.
"I have a record of being involved in these national security issues, which involve the highest responsibility and the toughest decisions that any president can make, and that is to send our young men and women into harm's way," McCain said.
Both candidates spent countless hours preparing for the debate.
Earlier this week, Obama's advisers put him through intense debate preparations in Tampa, Fla., with Greg Craig posing as McCain. The veteran Washington attorney defended former President Clinton during his impeachment proceedings.
However, aides said a trip to Washington to attend a White House meeting on the financial crisis with Bush and McCain Thursday kept Obama from preparing the way he had planned -- with full mock debates Thursday in Florida.
Obama's campaign also noted McCain's years of foreign policy experience give him home court advantage, an apparent attempt to lower expectations for the senator from Illinois.
"If he slips up, makes a mistake, or fails to deliver a game-changing performance," the Obama campaign claimed in a memo, "it will be a serious blow to his campaign."
But ABC News political consultant Torie Clark, who served in both Bush administrations, said Obama might have his own experience advantage stemming from his dogfight with Sen. Hillary Clinton, D-N.Y., for the Democratic presidential nomination.
"He had more experiences where it was Barack Obama and Hillary Clinton one-on-one almost," Clark said. "So, he's used to the two-person format -- more than McCain. When McCain was debating this spring, it was often a cast of thousands up there. And the fact that he did not deliver a stellar performance did not really stick out as much."
And because McCain is behind in the polls, he might have been considered the debate underdog, ABC News senior political reporter Rick Klein said before the event.
"I do think, in the end, there's more pressure on the person who's down," Klein said. "He's got to do more to shake things up a little bit."
In addition, concerns about the economy are spiking among registered voters. That helped Obama post significant gains over McCain, according to the latest ABC News/Washington Post poll.