The Democrat, who has been criticized by Republican rivalfor not visiting Iraq since 2006, revealed his plans to The New York Times. He also declined McCain's invitation for a joint trip.
"I just don't want to be involved in a political stunt," Obama said, according to a report on the newspaper's Web site Wednesday.
"I think that if I'm going to Iraq, then I'm there to talk to troops and talk to commanders," he said in the interview. "I'm not there to try to score political points or perform. The work they're doing there is too important."
McCain said he was pleased to hear that Obama was considering making the trip.
"It's long overdue," he told reporters in Los Angeles.
But that apparently welcome news gave the rivals another opportunity to engage each other on major campaign issues - the war in Iraq and who possesses the leadership and judgement to be the next commander in chief.
McCain supports continued U.S. military involvement in Iraq; Obama opposes the war and wants to bring home the troops.
McCain said Obama "was driven to his position by ideology and not by the facts on the ground. And he does not have the knowledge or the experience to make the judgments. Presidents have to listen and learn. Presidents have to make judgments no matter how popular or unpopular they may be."
Obama, who spoke to reporters on his airplane Wednesday night as he flew home to Chicago, said it's "not relevant" that he hasn't been to Iraq since 2006 and that McCain was using the argument as a diversion.
"I don't think John McCain or the Bush administration have a very strong argument to make about their foreign policy, so they're going to try to come up with diversions or distractions and not argue the substance," Obama said.
Obama's campaign has been considering an overseas trip since last year to beef up his foreign policy credentials, but the extended fight for the Democratic nomination withhas delayed those plans.
"A trip is under consideration but no final plans have been made," spokesman Bill Burton said Wednesday.
The Illinois senator made his only trip to Iraq in January 2006 as part of a congressional delegation. McCain, a senator from Arizona, has been to Iraq eight times, most recently in March.
McCain has been criticizing Obama for his absence from Iraq, and the Republican Party joined the fray Wednesday by launching an online clock to count the days since last visited the war zone. By the GOP's count, it's been 871 days.
McCain seemed offended that Obama characterized the invitation for a joint trip as a political stunt, saying it showed Obama's "lack of appreciation of the importance of this issue."
"I don't think that people who serve there would believe that a visit to find out the facts by a person who wants to lead the country, would be a, quote, stunt," he said.
Obama also had harsh words for McCain's assertion that Obama is more willing to meet the heads of rogue states, such as Iranian President Mahmoud Ahmadinejad, than with Gen. David Petraeus, the top U.S. commander in Iraq.
In Reno, Nev., McCain asked: "Why is it that Senator Obama wants to sit down with the president of Iran but hasn't yet sat down with General Petraeus, the leader of our troops in Iraq?"
Obama said that was "just a typical sarcastic comment that doesn't have anything to do with substance and is patently untrue, since I just saw General Petraeus when he was testifying in Washington."