Struggling to reinvigorate his troubled campaign, McCain reiterated his longtime criticism that President Bush initially went to war without a plan to succeed. But he also backed the commander in chief's recent troop increase and said Bush is right to veto legislation that places conditions on the war.
"In Iraq, only our enemies were cheering" when House Democrats enthusiastically passed legislation setting a timetable for a troop withdrawal, the Arizona senator told cadets at the Virginia Military Institute.
"A defeat for the United States is a cause for mourning, not celebrating," he added.
In a quick counter to McCain, Democratic presidential hopeful Barack Obama challenged the Republican's assessment of improved security in Baghdad and argued that only a change in strategy will bring a responsible end to the conflict.
"What we need today is a surge in honesty," the Illinois senator said in a statement, contending that McCain was measuring progress in Iraq using "the same ideological fantasies" that led the U.S. into war.
Another Democratic contender, Sen. Chris Dodd, also said McCain is wrong.
"We don't need a surge of troops in Iraq. We need a surge of diplomacy," the Connecticut senator said in prepared remarks for an Iowa speech. "The Bush/McCain Doctrine is not succeeding. It is failing."
McCain has staked his candidacy on the war's outcome, planting himself firmly on the side of the president he hopes to succeed and the three in four Republicans who view the war as a worthy cause. Most Americans, however, call it a hopeless effort.
His remarks came a week after he made his fifth trip to Iraq, where he was criticized for saying he was cautiously optimistic of success even as he toured the capital under heavy military guard. Iraqis accused him of painting too rosy a picture and U.S. critics argued he was out of step with reality.
In a CBS News poll released Wednesday, 39 percent said when McCain talks about Iraq, he makes things sound better than they really are while 29 percent said he was describing the situation accurately. The poll, conducted before the speech, surveyed 480 adults and had a margin of sampling error of plus or minus 5 percentage points.
The Iraq episode threatened to undercut McCain's credibility on a signature issue — defense. Wednesday's address, to several hundred uniformed cadets at the military college's Jackson Memorial Hall, was intended to counter his critics and put his faltering presidential bid back on course.
The cadets mostly remained silent as he spoke but gave him a standing ovation when he finished the speech.
In the speech filled with rhetoric for the GOP base, McCain portrayed himself as a leader who puts the country's interests above politics and as the most qualified Republican candidate to counter Democratic calls for withdrawal.
"Lets put aside for a moment the small politics of the day," he said. "The judgment of history should be the approval we seek, not the temporary favor of the latest public opinion poll."
He ignored his GOP rivals, all of whom support the president on the war but none of whom has McCain's military experience or has been as closely aligned with the conflict as the senator.
Instead, McCain assailed Democrats who control Congress, including "their leading candidates for president." It was a reference to Sens. Hillary Rodham Clinton of New York and Obama. Both voted for a troop withdrawal timetable.
McCain called the Democrats' pullout policy politically expedient but strategically disastrous. He accused Democrats who control Congress of acting in "giddy anticipation of the next election."
McCain said those like him who support Bush's troop increase chose the "hard road" but "right road."
"Democrats, who deny our soldiers the means to prevent an American defeat, have chosen another road," he said, referring to the standoff between Democrats and Bush over war funding and a timetable. "It may appear to be the easier course of action, but it is a much more reckless one, and it does them no credit even if it gives them an advantage in the next election."
A former Navy pilot and Vietnam prisoner of war, McCain is the only top-tier GOP candidate to have served in the military and he is the senior Republican on the Senate Armed Services Committee.