THE LATEST CRISIS in Afghanistan strikes at the heart of the U.S. strategy for preventing the country from reverting to Taliban rule or becoming a base for al-Qaeda. If those goals are to be achieved, the Afghan security forces that have been recruited, trained and equipped at enormous cost over the past several years must be sustained — something that will require continued training and advising by NATO, and heavy outside funding, for many years to come. That prospect seemed to be endangered last week when four U.S. soldiers were killed by Afghans in uniform. After an attack inside the Interior Ministry in Kabul, U.S. and NATO advisers were withdrawn from all ministries.

Fortunately, Pentagon and White House officials are describing the move as temporary and have said that the Obama administration and NATO remain committed to the underlying strategy. Yet the episode seems likely to strengthen those in and outside the administration who seek to accelerate the drawdown of U.S. troops next year and slash funding for Afghan forces. While perhaps appealing to voters in an election year, those steps would only compound the challenges facing the Afghan mission.

The probable trigger for the latest attacks on U.S. soldiers was the mistaken but inexcusable burning of Korans at the U.S. air base in Bagram, an incident for which President Obama rightly apologized. Republican presidential candidates were foolish to criticize Mr. Obama’s gesture, which prompted Afghan President Hamid Karzai to call for an end to violent anti-American demonstrations. It’s worth noting that Afghan security forces have been defending U.S. installations and personnel and suffered their own casualties in the process. Meanwhile, Afghan forces elsewhere in the country have continued to carry out joint operations with U.S. troops.

The popular backlash in Afghanistan nevertheless reflects deeper problems. There is understandable weariness with foreign troops after more than a decade of inconclusive war; resentment at the death of civilians in NATO operations; and frustration with the corruption and fecklessness of a U.S.-backed government. The Obama administration’s poor handling of Mr. Karzai has magnified these problems, while its setting of politically motivated timetables for troop withdrawals and aggressive pursuit of negotiations with the Taliban has convinced many Afghans that the United States is preparing to abandon the country.

The only secure and honorable means of exit is to finish the work of creating an Afghan army and police force capable of defending the country from the Taliban and other extremists, with backup from U.S. special forces and air power. Achieving that goal by the end of 2014, the current NATO timetable, will be hard enough, as the events of the past week vividly show. If the Obama administration chooses to accelerate the timetable or significantly reduce the funding — and thus the size — of Afghan forces, it will become nearly impossible.