The Arizona senator, who was Obama's Republican opponent in last year's presidential election, said it is folly to think the Taliban can be allowed to grow stronger in Afghanistan without benefiting Al Qaeda, the terrorist network that attacked the United States in 2001.
"They will become inextricably tied," McCain told CNN's "State of the Union" in an interview for broadcast Sunday.
McCain said he sympathized with Obama, who faces a difficult choice about Afghanistan troop levels and whether to focus the fighting more narrowly on terrorists or more broadly on Taliban insurgents.
McCain said he did not think the United States can win in Afghanistan unless Obama sends at least 40,000 more troops to augment the 68,000 now there. He agreed with those who see 40,000 new troops as the desire of Gen. Stanley McChrystal, the top U.S. commander in Afghanistan, although McChrystal gave Obama a range of options.
To reject the advice of those who say a significantly larger U.S. presence is needed, McCain said, "would be an error of historic proportions."
McCain, the top Republican on the Senate Armed Services Committee, also said he didn't think the Obama administration was "trying to muzzle" McChrystal from speaking out about his war-fighting approach. "He certainly understands that the chain of command has to be observed. But also, at the same time, since he has responsibility, I think he should be consulted very heavily and frequently."
McCain said the corruption in Afghan President Hamid Karzai's government "has got to stop."
He said Karzai's brother, Ahmed Wali Karzai, accused by some of drug trafficking, should leave the country.
Separately, the head of the U.N. mission in Afghanistan acknowledged on Sunday there was "widespread fraud" in the August presidential election, but refused to give specifics or lay blame to avoid influencing the recount.
McCain's interview was conducted Friday, a few hours after Obama won the Nobel Peace Prize and a few hours before Obama assembled his war council to hear military officials make their case for deploying tens of thousands of additional troops in Afghanistan.
White House discussions have sharpened the mission's focus to fighting Al Qaeda above all other goals and downgraded the emphasis on defeating the Taliban, a senior administration official who participated in the discussions said Thursday. The official was authorized to talk to The Associated Press but not to be identified because the discussions were private.
Under the evolving strategy, the official said, the U.S. would fight only to keep the Taliban from retaking control of Afghanistan's central government and from turning the country back into the sanctuary for al-Qaida that it was before the 2001 invasion.
McCain said the Taliban are "the most cruel and oppressive and repressive people" and that it would be "very distasteful to see them in power anywhere." Asked whether the U.S. policy for Afghanistan should mean trying to integrate some Taliban, McCain said, "Part of the strategy will clearly be that."
A focus on Al Qaeda is the driving force behind an approach being advocated by Vice President Joe Biden as an alternative to the McChrystal recommendation for a fuller counterinsurgency effort inside Afghanistan.
Biden has argued for keeping the American force level around the 68,000 already authorized, which includes the 21,000 extra troops Obama ordered this year. The vice president proposes significantly increasing the use of unmanned drones and special operations forces.
McCain said a "counterterrorism strategy" that relies heavily on intelligence and narrowly targeted missile strikes failed in Iraq and will fail in Afghanistan.