Moments earlier, his Democratic rival, , said in a speech in Washington that the U.S. must end the war in Iraq and that Afghanistan, by contrast, is "a war that we have to win."
McCain has described Obama's call for withdrawal from Iraq as tantamount to declaring defeat and points to the lower levels of violence in Iraq as evidence that sending additional U.S. troops there has been a successful strategy.
"Sen. Obama will tell you we can't win in Afghanistan without losing in Iraq. In fact, he has it exactly backwards," McCain told a town hall meeting. "It is precisely the success of the surge in Iraq that shows us the way to succeed in Afghanistan."
McCain added: "I know how to win wars. And if I'm elected president, I will turn around the war in Afghanistan, just as we have turned around the war in Iraq, with a comprehensive strategy for victory."
McCain laid out a blueprint for intensified military efforts in Afghanistan, where nine U.S. soldiers were killed and 14 injured in a militant attack Sunday, the U.S. military's highest death toll there in three years.
"The status quo is not acceptable. Security in Afghanistan has deteriorated, and our enemies are on the offensive," he said. "From the moment the next president walks into the Oval Office, he will face critical decisions and crucial decisions about Afghanistan."
Three more brigades should be sent to Afghanistan, McCain said, as well as a presidential envoy to deal with countries vying for power in the region.
In his speech, McCain said the extra brigades could be brought to Afghanistan as troops are removed from Iraq, but speaking later to reporters he hedged on whether some of those troops could come from NATO instead of the United States.
He also insisted there was a "vast difference" between Obama's call for more troops in Afghanistan and his own.
Obama "has no strategy," insisted McCain. "All he has done is say we need more troops."
McCain contends more foreign troops won't be enough to bring security to Afghanistan.
The Afghan army must be doubled to about 160,000 troops, he said, and he called on foreign countries to help pay for the cost of the increase. The increase in security problems has come even with more NATO troops in Afghanistan. McCain said the area needs a supreme unified military commander in charge of all the forces in the region to mount an effective counterinsurgency program.
The border with Pakistan is particularly troublesome for U.S. anti-terrorism efforts in the region. In his town-hall comments, McCain faulted Obama for saying that he would consider unilateral military action in Pakistan to strike at al Qaeda leadership.
"In trying to sound tough, he has made it harder for the people whose support we most need to provide it. I won't bluster and I won't make idle threats. But understand this, when I am commander in chief, there will be nowhere the terrorists can run and nowhere they can hide," he said.
McCain also proposed appointing a White House czar on the Afghanistan war.
President Bush has already appointed a so-called "war czar" for both Iraq and Afghanistan, but McCain said he wanted someone reporting to him with direct responsibility for Afghanistan. Obama said Monday he would send at least two more brigades to Afghanistan.
"I will get Osama bin Laden and bring him to justice," McCain said of the al Qaeda leader the U.S. has pursued futilely since the group's Sept. 11, 2001, terrorist attacks.