Two indelible, humiliating images are certain to endure from the final days of the Afghan war.

The first came in the White House on July 8 when President Biden was asked if the U.S. departure from Afghanistan carried echoes of Vietnam. “None whatsoever. Zero,” he replied, testily. “There’s going to be no circumstance where you see people being lifted off the roof of an embassy.”

The other is an image just as searing as those from the fall of Saigon: Desperate Afghans clinging to the wheel wells of a C-17 U.S. Air Force cargo jet as it taxis for takeoff at Kabul’s international airport.

Together, the two moments embody a malady that has infected the war from its earliest days and helps to explain the catastrophic collapse of the Afghan government and its military. Senior U.S. officials in Washington and Kabul have continually failed to appreciate how difficult the mission would be, how badly it was going and how little they had achieved.

“It’s not a good image . . . that we were burning documents because our embassy was going to be overrun. It is not a good image to take down the flag,” said Sue Gordon, a 25-year veteran of the CIA who served as deputy director of national intelligence before resigning in 2019. “These images suggest that we did not understand the situation.”

The failure to grasp the depth of the dysfunction in Afghanistan dates to November 2001 when President George W. Bush ordered the Pentagon to begin planning for an invasion of Iraq. Suddenly, many of the most critical intelligence assets and the most potent ground combat forces were shifted to a focus on Baghdad. Afghanistan, in the words of one Bush-era White House official, became a “distraction and a sideshow.”

And it carried through until this July when Biden described the Afghan military as a force of 300,000 troops — “as well equipped as any army in the world.”

In fact, former defense and White House officials said that Biden’s figures were a fantasy and that by late 2020 as many as half of the Afghan army forces had stopped showing up for duty. “The desertion numbers were very high,” said a former senior defense official, who spoke on the condition of anonymity to discuss sensitive intelligence. “We were told that 100,000 of their soldiers had put down their guns and that in all likelihood the numbers were much worse.”

A senior White House official said the Biden administration was prepared for the chaos in Afghanistan and had pre-staged thousands of U.S. troops in case the Taliban forces made rapid gains. “This is not the worst case scenario,” the official said. “No Americans are under fire. What we’re seeing is not Taliban attacking [the embassy]. It is desperate Afghans trying to get out.”

It’s a defense that carried little weight with even the president’s staunchest allies in Congress. Sen. Mark R. Warner (D-Va.), the chairman of the Senate Intelligence Committee, called the images from Kabul’s airport and its capital “devastating.” He vowed to work with others in Congress to determine “why we weren’t better prepared for a worst-case scenario involving such a swift and total collapse of the Afghan government and security forces.”

An entire generation of U.S. military officers came of age in the aftermath of the Vietnam War with a guiding mission to make sure the country never had to endure the sorts of humiliating images from Saigon that were repeated this week in Kabul.

“The disgraceful performance of Biden and what passes for military leadership today in managing this debacle borders on criminal,” said retired Col. Gary Anderson, who joined the Marines in the final years of that losing Vietnam effort.

In 2012, Anderson served in Bala Murghab, a remote district near Afghanistan’s border with Turkmenistan. Within a week of U.S. troops leaving the area in 2012, Anderson said, the local army commander and police chief “had cut deals with the Taliban, just as happened throughout the country this last week.”

Former senior U.S. officials said those in charge of the war effort over several administrations often seemed unwilling to accept — or unable to grasp — clear signs of failure or futility in Afghanistan.

Pentagon officials were almost constantly at odds with CIA experts over “district assessments” that cast doubt on how much territory the American-backed Afghan government controlled across the country.

In 2019, U.S. spy agencies delivered a sweeping assessment known as a National Intelligence Estimate of the conflict that warned many of America’s often-stated objectives were in jeopardy even with a continued U.S. military presence, and without direct American backing all but destined to collapse.

“We would run into really serious battles with the Pentagon, which would say, ‘We’ve got boots on the ground, we know the truth,’ ” said a former senior U.S. intelligence official.

The diverging views on the war were a reflection of the institutional predispositions of military planners groomed to accept even the most daunting missions and find ways to deliver results.

In Afghanistan, “you had good people who tried mightily believing they could do it,” the former intelligence official said. “And in the end are forced to face the reality that they couldn’t.”

On Monday, many of those senior military officials were operating on only a few hours sleep after staying up much of the night fielding calls from former Afghan colleagues who were stranded in the country or at the airport and were terrified that they would soon be killed. Some couldn’t understand why the White House and the Pentagon had decided to abandon Bagram air base to looters a month ago, long before Afghans who had worked for the United States and were in danger could be evacuated.

Unlike Kabul’s airport, which is located in the middle of the city, Bagram would have been far easier to secure.

“Any military official who said it is okay to leave all the airfields before we have everyone out should be fired tomorrow,” said one retired Army general who served multiple tours in Afghanistan. He spoke on the condition anonymity because he is still working with the Biden White House to get some of his former Afghan colleagues out of the country.

The only thing left of the U.S. mission is to “get out the people who sacrificed and suffered for us,” said Carter Malkasian, a longtime adviser to the U.S. military and author of the recently released history “The American War in Afghanistan.”

Malkasian defended the attempts of the military and the Biden administration to end the war in an orderly fashion. The failures spoke to the difficulty of predicting any short-term outcomes in Afghanistan and “human nature,” he said.

Biden didn’t ignore the signs of potential collapse, Malkasian said. Rather, he made a “hard choice” to end the losing war despite the “costs and consequences” that the United States and its Afghan partners would endure. Biden echoed this sentiment on Monday, saying that he was “deeply saddened” by the chaos but that he could not allow U.S. troops to pursue a mission that was “not in our national security interests [and] not what the American people want.”

Rep. Seth Moulton (D-Mass.), a Marine veteran, described the scene at Kabul airport as “a moral and operational failure.”

The video and pictures also spurred him to reflect on his own war.

“To your Afghanistan veterans and their families,” he said in a statement, “I am too honest to stand here today and try to convince you that your sacrifice was worth it.”