President Barack Obama paid a secret visit to the air base in May 2014. Afghanistan’s president at the time, Hamid Karzai, declined an invitation from American officials to meet Mr. Obama at the base, saying that doing so would be a breach of protocol, though the two leaders spoke by telephone.

Mr. Tillerson’s visit was his first to Afghanistan as secretary of state, and like nearly every other top American official to visit over the previous two decades, he said the country’s predicament was not nearly as dire as his own security precautions suggested.

“But I think if you consider the current situation in Afghanistan, and we were talking about this a few minutes ago, and you look a few years in the past to what the circumstances were, Afghanistan has come quite a distance already in terms of creating a much more vibrant population, a much more vibrant government, education system, a larger economy,” he said in a small windowless conference room during a hurried eight-minute news conference. “So there are opportunities to strengthen the foundations of a prosperous Afghanistan society.”

Mr. Tillerson saw none of that hoped-for blooming.

When the huge maw of the C-17 aircraft that he flew into Bagram opened, he was greeted by Gen. John Nicholson, the commander of United States operations in Afghanistan, along with a sizable contingent of soldiers and security guards.

They piled into a motorcade and drove the few minutes to the base’s bunkerlike headquarters, passing hangars constructed by Russia, another of the foreign forces to be humbled in Afghanistan. Huge concrete blast walls lined much of the route. Helicopters patrolled the perimeter, and two security blimps equipped with long-range cameras hovered.