Senator McCain, the presumptive Republican nominee, was in Chicago to speak about the U.S. role in the global economy.
But McCain opened his speech with an attack on Senator Obama. McCain seized on remarks Obama made the previous day in which he described the threat posed by Iran to the United States as tiny compared to the threat once posed by the Soviet Union.
McCain accused Obama of underestimating the threat Iran poses to the United States.
"Senator Obama has declared and repeatedly reaffirmed his intention to meet the president of Iran without any preconditions, likening it to meetings between former American presidents and the leaders of the Soviet Union," he said. "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."
Obama was quick to respond to McCain's attack during a campaign event in Billings, Montana.
"And so I have made it clear for years that the threat from Iran is grave, but what I have said is that we should not just talk to our friends, we should be willing to engage our enemies as well," he said. "That is what diplomacy is all about. The reason Iran is so much more powerful now than it was a few years ago is because of the Bush-McCain policy of fighting an endless war in Iraq and refusing to pursue direct diplomacy with Iran. They are the ones who have not dealt with Iran wisely.
Last week, Obama accused McCain and President Bush of what he called dishonest and divisive attacks over his willingness to talk to Iran. Without mentioning Obama by name, President Bush compared those who would negotiate with terrorists and radicals to the appeasers of Nazi Germany prior to the Second World War.
The foreign policy exchange over Iran came on the eve of Democratic primaries in Kentucky and Oregon, the latest match-ups in the long running battle between Obama and rival Hillary Clinton for the Democratic Party's presidential nomination.
The latest polls give Obama a slight lead in Oregon. On Sunday, he drew a crowd of about 75,000 at a rally in Portland.
Senator Clinton is focused on Kentucky where a new poll gives her a huge lead over Obama.
Clinton told supporters in Kentucky she intends to keep campaigning right through the end of the primary season on June 3.
"So, I am going to make my case and I am going to make until we have a nominee," she said. "But we are not going to have one today and we are not going to have one tomorrow and we are not going to have one the next day. And if Kentucky turns out tomorrow, I will be closer to that nomination because of you."
Obama has a solid lead in the overall delegate count and continues to gain the support of Democratic superdelegates. Superdelegates are Democratic officeholders and party activists free to support either candidate.
The latest superdelegate to line up behind Obama is veteran Senator Robert Byrd of West Virginia. Byrd decided to support Obama even though Clinton easily defeated Obama in the West Virginia primary last week.
After Tuesday's contests in Kentucky and Oregon, only three more Democratic primaries remain. Puerto Rico holds a primary on June 1, followed by South Dakota and Montana on June 3.