His comments come after the US death toll hit 4,000 in Iraq and following clashes across the country between Shia militias that have left hundreds dead.
"To promise a withdrawal of our forces from Iraq, regardless of the calamitous consequences to the Iraqi people, our most vital interests, and the future of the Middle East, is the height of irresponsibility,'' he said.
"It is a failure of leadership."
McCain said any withdrawal could turn Iraq into a haven for terror, arguing that the consequences of America's failure in Iraq would "almost certainly require us to return to Iraq or draw us into a wider and far
McCain also criticised his Democratic rivals, Hillary Clinton and Barack Obama, suggesting their promises to withdraw troops if elected were motivated by ambition rather than honesty.
"I do not believe that anyone should make promises as a candidate for
president that they cannot keep if elected," he said.
Obama responded in a statement that it was a failure of leadership "to support an open-ended occupation of Iraq that has failed to press Iraq's leaders to reconcile, badly overstretched our military, put a strain on our military families, set back our ability to lead the world and made the American people less safe".
McCain faced criticism earlier this year when he said that US forces could remain in Iraq for up to 100 years if necessary.
His comments come the day before General David H Petraeus, the top commander in Iraq, and ambassador Ryan Crocker are due to testify to US congress over the Iraq war.