AFGHAN PRESIDENT Hamid Karzai kicked off his traditional loya jirga assembly in Kabul on Wednesday with another populist demand at the expense of the United States: House searches and night raids by U.S. and other NATO forces must cease. His bravado may have disguised — perhaps intentionally — the fact that Mr. Karzai is attempting to use the assembly to do both himself and the United States a considerable political favor. Let’s hope he succeeds.

The Afghan president is trying to build public support for a military partnership with the United States, an agreement that could cover a decade following the scheduled end of the NATO military mission in 2014. Vitally for the United States, the deal would allow it to continue using bases in Afghanistan, which will be needed for counterterrorism operations against al-Qaeda. Vitally for Mr. Karzai, Afghanistan would get U.S. funding, training and advising for its army, which would quickly collapse without such help.

More so than the negotiations the Obama administration is trying to pursue with Pakistan and the Taliban, the strategic partnership accord with Afghanistan could ensure that the achievements of the last decade — including the rout of al-Qaeda and clearing of Taliban fighters from much of the country — are not reversed. A deal could also mitigate the deleterious effect of the withdrawal timetable established by President Obama, which encourages the Taliban and its backers in Pakistan to wait out the United States rather than settle with Mr. Karzai’s government.

Completing the accord, which has been under negotiation for months, will not be easy for Mr. Karzai. He is under considerable pressure from Afghanistan’s neighbors — including Pakistan, Iran and Russia — not to allow a long-term U.S. military presence. He also has to satisfy Afghans weary of operations by Western troops and the collateral damage they sometimes cause. Hence the president’s showy rhetoric about ending searches and night raids.

In fact it should be possible to finesse that issue by putting Afghan forces in the lead of more operations, as U.S. commanders are already doing. Satisfying Afghan demands for a multiyear commitment of U.S. resources is more difficult, since the administration can’t bind appropriations by future Congresses. Yet the reality is that the Afghan army that NATO has painstakingly constructed will require at least $3 billion annually in outside funding to function. A U.S.-Afghan agreement to sustain it, with the help of U.S. trainers and advisers, would send a powerful message to the Taliban and its sponsors.

Both supporters and opponents of the current U.S. strategy in Afghanistan ought to support a partnership agreement. It offers the best way to sustain a pro-Western Afghan government past 2014, and it can preserve the U.S. ability to strike quickly and effectively at emerging terrorist threats in Afghanistan and Pakistan. We hope the deal can be concluded quickly — and that Mr. Karzai can sell it to his country.