McCain, the Republican standard-bearer for November's election, meanwhile won backing from President George W Bush for his demand to open the US coasts to offshore oil drilling at a time of sky-high fuel prices.
Obama convened a new group of advisers on security policy that included prominent backers of his defeated primary rival Hillary Clinton, including former secretaries of state Madeleine Albright and Warren Christopher.
The Illinois senator also met with about 40 retired generals and admirals for an overview of the US armed forces, as he parried a second day's offensive from the McCain camp about his plans to fight Islamic extremism.
"I refuse to be lectured on national security by people who are responsible for the most disastrous set of foreign policy decisions in the recent history of the United States," Obama said after the security advisers' meeting.
"Because the record shows that George Bush and John McCain have been weak on terrorism. Their approach has failed. Because of their policies, we are less safe, less respected, and less able to lead the world.
"It's time to turn the page," he said, demanding a "responsible" end to the war in Iraq and a new focus on the Taliban and Al-Qaeda in Afghanistan.
McCain supporters again slammed a call by Obama for suspected extremists to be prosecuted, in light of a Supreme Court ruling last week allowing Guantanamo Bay detainees to challenge their detention in US courts.
In November's election, former New York mayor Rudy Giuliani told reporters, "The American people are going to have a choice: do we want to be on offense or on defense against terrorism?"
Giuliani, whose own bid for the Republican nomination this year fell flat, lashed out at Democratic attacks on Bush's "war on terror" in a media conference call.
"The reality is that this country has been kept safe over the last seven years," said the former mayor, who helped guide New York through the carnage of September 11, 2001.
Obama's foreign policy adviser Susan Rice said the Democrat offered a "smart strategy" to fight terror, allying law enforcement to worldwide military and diplomatic action that would repair America's reputation with its allies.
"It is in stark contrast to the Bush-McCain self-defeating and failed approach," she said.
Bush, at a Republican fundraiser on Wednesday, excoriated Democrats he described as defeatists who "still call for retreat" in Iraq. And while Bush did not mention him by name, he took a shot at Obama.
"In a time of war we need a president who understands that we must defeat the enemy overseas so we do not have to face them here at home, and that man is John McCain," Bush said.
Polls suggest though that this year's election will be fought not on the 2004 theme of who can best keep America safe, but who can best revive its economy and help hard-pressed voters at risk of losing their homes and jobs.
New surveys by Quinnipiac University had Obama besting McCain in three pivotal swing states for the first time – 52-40 per cent in Pennsylvania, 48-42 per cent in Ohio, and 47-43 in Florida.
Obama has also enjoyed a bounce in national polls since seeing off Clinton's dogged challenge, as Americans reel from surging gasoline prices, home foreclosures and unemployment.
In answer to the burden of pump prices, McCain on Tuesday reversed his own opposition to offshore drilling. That drew scorn from Obama, who said any oil from such exploration was years away and would come at an environmental cost.
But Bush, at a White House press event Wednesday, lent new momentum to his fellow Republican's proposal by endorsing the lifting of a 27-year federal moratorium on offshore drilling.
"Congress must face a hard reality. Unless members are willing to accept gas prices at today's painful levels or even higher, our nation must produce more oil, and we must start now," Bush said.
McCain also called on Wednesday for the construction of 45 new nuclear reactors by 2030 to help wean the US economy off foreign oil.
But Missouri Senator Claire McCaskill, a Democrat backing Obama, said McCain was "shilling for Saudi Arabia" with his campaign proposals on energy policy.