In discussing Iraq, he avoided restating his belief that the U.S. was "winning" the war but stressed the need for a substantial troop presence.
"We have incurred a moral responsibility in Iraq," he said. "It would be an unconscionable act of betrayal, a stain on our character as a great nation, if we were to walk away from the Iraqi people and consign them to the horrendous violence, ethnic cleaning and possibly genocide that would follow a reckless, irresponsible and premature withdrawal."
On Iran, McCain said that the United States and allies must do "all in our power" to keep the country from developing nuclear weapons. But he notably stopped short of saying that the United States should consider using military force, as he has in the past.
He also said America and China were "not destined to be adversaries." In response to a question later, he said any U.S. response to recent unrest should be limited to urging Beijing to begin conversations with Tibetans "to give them a better and freer life."
Democrats, who have sought to portray McCain as a reckless militarist, charged after the speech that his embrace of diplomacy was fraudulent.
"John McCain's empty rhetoric today can't change the fact that he has steadfastly stood with President Bush from Day One, and is now talking about keeping our troops in Iraq for 100 years," Democratic National Committee Chairman Howard Dean said in a statement. "His new appreciation for diplomacy has no credibility."
McCain's positions on foreign policy are diverse and include some with a neoconservative bent and others more in tune with more moderates and pragmatic voters.
McCain has said that because of his appeal to independents and some Democrats, he believes he can be competitive in California, a state last won by a Republican presidential contender in 1988, when former President George H.W. Bush ran.
Speaking with reporters after the speech, McCain advisors pointed out the candidate's self-description as a "realistic idealist" -- a phrase that reflects the combination of his "realist" and "neoconservative" impulses.
They singled out as particularly significant portions of the speech that dealt with the need for more collective international action, his distaste for war, his call for nuclear disarmament and his declaration that the war on terrorism is not primarily a military effort.