Senate Armed Services Chairman John McCain said on Thursday that the U.S. needs to model its troop stay in Afghanistan on the long commitment the nation made to South Korea.

American forces have been stationed in the South for over 60 years. They repelled the invasion from the communist North, then stood at the border to block a second one as they turned the local armed forces into one of the best in the world. Nearly 30,000 are stationed there today.

At a hearing to confirm the next commander in Afghanistan, Army Lt. Gen. John Nicholson, who will succeed Gen. John Campbell, Mr. McCain criticized President Obama’s plan to bring the U.S. force level from 9,800 to 5,500 by Jan. 1. without regard to conditions on the ground.

“As the security situation in Afghanistan continues to deteriorate, it makes no strategic or military sense to continue the withdrawal of American forces,” Mr. McCain said. “Indeed, our military commanders increasingly realize that preventing the reemergence of terrorist safe havens in Afghanistan will require a long-term partnership with Afghan government and military similar to the U.S. role in South Korea or Colombia.”

U.S. special operations units have maintained a long presence in Colombia advising forces on how to combat Marxist rebels and the vibrant illegal drug industry.

Gen. Nicholson, a former operations chief in Afghanistan, was noncommittal on what troop level he will recommend once he takes command and assesses the battlefield. He said American troops will not be in Afghanistan in an “endless sense.”

“We do need to think about an enduring commitment” to Afghanistan, said the former commander of the 82nd Airborne Division.

He will find a troubling landscape. The Taliban has been resurgent and controls four districts. Al Qaeda is reestablishing itself in southern Afghanistan. And the ultra violent Islamic State has opened a franchise in the east.

All the while, the Afghan National Security Defense Force continues to suffer corruption and attrition, and does not respond well to Taliban offenses, commanders have said.

Mr. McCain urged Mr. Obama not to repeat what happened in December 2011, when all U.S. forces left Iraq. Months later, al Qaeda in Iraq reemerged and then its successor, the Islamic State, rose up in Syria and invaded western and northern Iraq where its fighters hold territory today. Mr. Obama was forced to reintroduce over 3,000 troops into Iraq and begin a broad air war over Iraq and Syria.

“By now, we should have learned from the precipitous withdrawal from Iraq and the disaster that ensued that wars do not end because politicians say so,” said Mr. McCain, Arizona Republican. “Nor will any politician be able to schedule an end to the threat of radical Islamist terrorism emanating from Afghanistan or the region more broadly.”