McCain, Obama's Republican opponent in last year's election, also argued for the president to approve a call for additional troops by Gen. Stanley McChrystal, the U.S. commander on the ground, and other military officers.
If Obama fails to do so, McCain said in a morning news show interview, it would "put the United States in much greater danger, because failure in Afghanistan" would run the risk of the nation turning into a base for attacks and the U.S. and its allies.
McCain appeared on ABC's "Good Morning America" on a day in which Obama holding a high-level White House meeting to discuss his Afghan strategy. His vice president, Joe Biden, Secretary of State Hillary Rodham Clinton, Defense Secretary Robert Gates and other members of his national security team were expected to take part.
McChrystal has written an assessment of Afghanistan saying that he thinks the war effort there likely will succeed only with the dispatch of large numbers of additional troops, in addition to the more than 68,000 there now.
The Obama White House has said repeatedly that the president would consider McChrystal's recommendations, and those of other advisers, carefully and methodically before announcing his next move. Obama has said the goal of the U.S. presence in Afghanistan is to disrupt, dismantle and destroy the al Qaeda terrorist network and its sympathizers.
"Time is not on our side," McCain said, "so we need a decision pretty quickly. I think history is pretty clear that when the Taliban took over, it became a base for attacks on the United States and our allies."
McCain said much more effort is needed in the wartorn Asian nation.
"There are still populated areas that need to be under control," he said. "You go in, you clear, you hold, you allow the political, economic and cultural life to continue. .. .There are great problems there, a corrupt government."
But the Arizonan also said he thinks the country is in no worse shape, even perhaps better off, than Iraq was at the time when then-President George W. Bush ordered the American military surge there late in his second term.
"We're talking about the inkblot strategy," said McCain, "where you go into the populated areas, you clear out the bad guys. ... That's what we did in Iraq, and that's the classic counterinsurgency."
"That's the debate here, between counterinsurgency and counterterrorism strategy," he added, saying the counterinsurgency plan was the better path to take.
"The people of Afghanistan don't want the Taliban back and the Karzai government has to clean up its act." McCain said the Afghan military "has been fighting very well. There just aren't enough of them."
McCain said he thinks the drawn-out debate over the Afghan war policy in the United States "may be perceived by some of our allies in Europe and Pakistan and that region as a bit of weakness."
He said he has sympathy with Obama, saying the president is getting pressure from the left wing of his own Democratic Party. But McCain also said, "He said this is a war of necessity, and I hope he'll stick to that. ... I hope and believe that he will make the right decision."