FACED WITH the difficult task of defending the U.S. mission in Afghanistan after a series of setbacks, Gen. John R. Allen underlined Tuesday some of the good news that has been overlooked recently. Testifying to the House Armed Services Committee, the top U.S. commander in Afghanistan pointed out that the Taliban has been greatly weakened by a NATO offensive in the south and by special forces operations against its commanders; attacks are down by a quarter so far this year compared to 2011.

The military gains are reversible, of course. But another important piece of Gen. Allen’s testimony concerned the continuing development of the Afghan army and police, which he said were on course to reach a strength of 352,000 men by October, compared to 140,000 in October 2008. The growing strength of those forces, the general argued, meant that NATO’s strategy for the war is still workable, and the best way forward: a gradual transfer of fighting responsibility to Afghan units between now and the end of 2014.

Gen. Allen’s assessment has the backing of President Obama, who to his credit is resisting calls for rapidly scaling back or even abandoning the Afghanistan mission. But if the United States is to achieve an acceptable outcome, more will be needed than presidential patience in an election year. Gen. Allen requires Mr. Obama’s help in three other important ways — only one of which appears to be on the White House’s to-do list at the moment.

The task the administration acknowledges is quickly completing a strategic cooperation agreement with Afghan President Hamid Karzai that would provide for U.S. military advisers and trainers as well as counterterrorism forces to remain in Afghanistan after 2014. Not only will those forces be needed to prevent the Taliban from regaining power in Kabul, but an accord on them is needed now in order to stabilize the shaky relationship between the U.S. and Afghan governments — and to persuade the Taliban that it cannot wait out a U.S. withdrawal. To finish the pact, U.S. and Afghan officials have to settle the sensitive question of how special forces “night raids” will be managed in the future; the right answer is to hand them over to Afghan units as quickly as possible.

If that can be done, the administration must still tackle the challenge of fostering a credible Afghan government that can manage the army and the country after 2014. An election is due that year, and Mr. Karzai has pledged not to run for another term as president. It’s important that the United States, United Nations and other outside parties begin to work on creating the conditions for elections that Afghans will accept as free and fair — and to commit to fully fund the Afghan army and government after 2014.

Lastly, Mr. Obama must do more to build support in the United States for his policy. The president has given just a handful of speeches on Afghanistan during his first term, and his recent public comments have focused on bringing troops home, rather than completing their mission. While Gen. Allen is doing his best this week, the most prominent advocate for continuing to put U.S. lives on the line should be Mr. Obama.