The likely GOP presidential nominee made the criticism Monday in Chicago, Obama's home turf.
"Such a statement betrays the depth of Senator Obama's inexperience and reckless judgment. These are very serious deficiencies for an American president to possess," McCain said in an appearance at the restaurant industry's annual meeting.
He was referring to comments Obama made Sunday in Pendleton, Ore.: "Iran, Cuba, Venezuela - these countries are tiny compared to the Soviet Union. They don't pose a serious threat to us the way the Soviet Union posed a threat to us. And yet we were willing to talk to the Soviet Union at the time when they were saying, `We're going to wipe you off the planet."'
A video clip of Obama making the comments was distributed Monday by McCain's campaign.
McCain listed the dangers he sees from Iran: It provides deadly explosive devices used to kill U.S. soldiers in Iraq, sponsors terrorists in Iraq and elsewhere in the Middle East and is committed to the destruction of Israel.
"The threat the government of Iran poses is anything but tiny," McCain said.
Responding to McCain, Obama told a town hall rally later Monday in Billings, Mont., "Let me be absolutely clear: Iran is a grave threat." But the Soviet Union posed an added threat, he said. "The Soviet Union had thousands of nuclear weapons, and Iran doesn't have one."
Obama said the threat from Iran had grown as a result of the U.S. war in Iraq. "Iran is the biggest single beneficiary of the war in Iraq," he said. "John McCain wants to double down that failed policy." If McCain is elected, Obama said, "We'll keep talking tough in Washington, while countries like Iran ignore our tough talk."
The alternative, Obama said, is to follow the example of Presidents Kennedy and Reagan who negotiated with the Soviet Union. Obama called for "tough, disciplined and direct diplomacy. That's what Kennedy did; that's what Reagan did."
Obama's "words sound strong, but he is playing defense, and you'd think he wouldn't want to be doing that, especially against John McCain," said CBS News correspondent Dean Reynolds.
Although the Democratic primary race rolls on, McCain and Obama have criticized each other as if they are in the general election campaign. On Friday, Obama called McCain's tough-guy foreign policy "naive and irresponsible;" McCain questioned whether Obama has the strength and judgment to be commander in chief.
At the heart of the dispute between the candidates is Obama's assertion that, as president, he would meet with leaders of these rogue countries without preconditions. Obama insists that direct engagement with the Soviets helped prevent nuclear war and, over time, helped to bring down the Berlin Wall.
McCain strongly disagrees with Obama's position; he argues such a meeting would lend international prestige to U.S. foes.
"An unconditional summit meeting with the next American president would confer both international legitimacy on the Iranian president and could strengthen him domestically, when he is very unpopular among the Iranian people," McCain said.
His remarks were interrupted for several moments by three protesters from the Code Pink anti-war group, one of whom yelled, "No war in Iran!" as she was hustled from the room.
McCain prefaced his speech to the National Restaurant Association with criticism of Obama but then focused mostly on economic issues. He said Obama and his Democratic rival, Hillary Rodham Clinton, would raise taxes and regulate businesses "more than ever."
The Arizona senator has been trying to counter the allegation by Democrats that McCain would continue Bush administration policies.
Yet McCain's arguments on Monday - on tax cuts, trade agreements and farm subsidies - mirror those of President Bush.
McCain said that letting the Bush tax cuts expire, as the Democrats would do, would raise taxes by a trillion dollars or more. And he said Obama was wrong to oppose the North American Free Trade Agreement, a pact that, though still controversial after more than a decade, resulted in an estimated $17 billion dollars in exports from Illinois alone.
McCain said farm subsidy payments, like those in the farm bill Congress recently sent to Bush, are the biggest obstacle to global trade deals. Like McCain, Bush dislikes the bill and is threatening to veto it.
"Here we are at a time when food prices are at historic highs, and farm income is up by 56 percent in just the past two years," McCain said. "Yet even now, the Congress has voted to give billions of dollars in subsidies to some of the biggest and richest agribusiness corporations in America."
The Illinois Farm Bureau and other farm groups point out that high energy prices have driven up the costs farmers pay to produce their crops.
"Farmers are in the middle of planting the most expensive crop in history," Illinois Farm Bureau President Philip Nelson said last week.
Acknowledging he was in Obama territory, McCain said he agreed with Illinois Democrats that Obama is the right choice to be their senator.
"I couldn't agree more, and I promise to do everything in my power to help him finish his first term in the United States Senate," McCain quipped.