President Joe Biden’s defense of the U.S. withdrawal from Afghanistan was callous, self-serving and deeply unconvincing. Above all, it was beside the point. The question is no longer whether U.S. troops should have stayed. It’s how the U.S. can minimize the damage caused by this grievously bungled exit.

Some of the gloating among U.S. rivals is overdone, but there’s no doubt U.S. credibility has suffered a crippling blow. Abandoning loyal Afghan allies to their fate will haunt future U.S. interventions around the world. Friends have been snubbed. Rival powers will take heart. Terror groups that were always going to be hard to target from afar are now set to grow bigger and faster than before. Recovering from this debacle will require long, painstaking effort.

It must start with telling the truth. So far, the president has refused to recognize this misadventure as a failure. If a mess of this order doesn’t qualify, it’s hard to know what would. Biden needs to be honest, not blithely unyielding in his own defense.

Next comes securing the evacuation of Americans and their allies. The U.S. should do all it can to ensure the safe passage of Afghans who qualify for U.S. visas to the Kabul airport — and to keep planes flying until they can get out. This should include not just Afghans who worked directly for the U.S. military but those affiliated with U.S.-based media and aid organizations, who are officially supposed to apply for visas from a third country. A new humanitarian parole program, similar to those established earlier for South Vietnamese and Cubans, is needed so they and other vulnerable Afghans can be brought directly to Guam or the U.S. mainland for processing.

The U.S. should also drive global efforts to head off a broader refugee crisis. Neighbors such as Iran and Pakistan — which already house millions of Afghan refugees — are shutting their borders to more. Europe’s governments are warning asylum-seekers against trying to reach the West. The U.S. should lead by example, committing to take its fair share of any outflow. It should also rally donors to fill the gaping hole in the region’s United Nations refugee funding. And it should use next week’s G-7 talks to advance a broader resettlement plan for Afghans, like the one created for Indochinese refugees after the Vietnam War.

Newsletter signup for email alerts

Afghans who remain will also need help. Even before the Taliban takeover, Afghanistan faced a burgeoning humanitarian crisis, with nearly half the population needing aid and more than 550,000 Afghans forcibly displaced from their homes just this year. In addition to ensuring the U.N. and relief organizations have the resources they require, the U.S. should work with its Security Council partners to ensure the Taliban allow aid to flow freely.

Next, the U.S. must come to grips with what is likely to be an expanded terror threat under the Taliban. Intelligence agencies will have to rededicate resources and ramp up surveillance to track any surge in jihadists to the country. They should strengthen contacts with former CIA assets and Afghan commandos, who might provide eyes and ears on the ground. Regional powers such as Pakistan, Russia and China don’t share the same goals as Washington, but all fear a resurgence of extremism. They must be urged to coordinate pressure on the Taliban to rein in the most dangerous groups.

Finally, the Biden administration should launch a comprehensive effort to rebuild trust with allies and partners. The president’s failure to speak with allies promptly after Kabul fell is inexcusable. In putting this right, there are no shortcuts. It will require more than fine speeches and democracy summits.

The U.S. can help India deal with a renewed terrorism threat, for instance. It previously expected its Quad and NATO allies to support its strategic priorities in the region, but now Washington will have to listen more attentively to their concerns. It should strive to eliminate needless trade frictions with Europe and engage seriously in trade talks with Asian nations, so they see clear benefits to a closer relationship with the U.S. Not least, if and when rivals test the country’s resolve, as the Soviets did after the fall of Saigon, the U.S. will have to respond swiftly and smartly.

Recovering from this setback will take time, effort and resources. It will also require close and concerted cooperation with allies. The work starts now.

©2021 Bloomberg L.P.

Distributed by Tribune Content Agency, LLC.