DURING his first visit to Washington as Afghanistan’s president, Ashraf Ghani said everything his infuriating predecessor, Hamid Karzai, did not. Where Mr Karzai could sound insultingly ungrateful, Mr Ghani heaped thanks on his American hosts for the roughly $1 trillion spent in Afghanistan since 2001, and the more than 2,200 American lives lost—even, at a Pentagon ceremony, addressing some of the families of those who died. He emphasised a determination to crack down on corruption. And he won praise from President Barack Obama for having “taken on the mantle of commander-in-chief in a way that we have not seen in the past from an Afghan president.”

Mr Ghani comes away with a prize, of sorts: a tweaking of Mr Obama’s plans to pull American forces out of Afghanistan. Instead of nearly halving the American force, to 5,500, from the middle of this year, Mr Obama said all 9,800 soldiers would now remain until the end of the year. They will not be sent into combat but rather continue in the “train, advise and assist” role they adopted at the end of 2014. By the end of 2016, when Mr Obama leaves office, even that supporting role will supposedly be over, with only a military assistance office remaining.

Opinions polls show that Afghans fear a complete departure of foreign troops. The pause should help Afghanistan get through the “fighting season” against the Taliban and other insurgents in the warmer months of this year. The country’s security forces need continuing training and they still struggle with logistics and basic management. American military types in Kabul, the capital, blame an alarming shrinkage in the size of the Afghan army last year not on a lack of appetite among young Afghans to join security forces suffering horrendous casualties fighting the Taliban, but on the failure of ministries to meet recruitment targets because they do not have the bureaucratic capacity.

The hope now is that a strong showing by Afghan forces in the coming months, even if losses remain high, will help nudge the insurgents to the negotiating table. It is something that Pakistan, the Taliban’s former sponsor, is also encouraging, now that Mr Ghani is also mending fences with Afghanistan’s eastern neighbour.

Nor is it clear that the withdrawal of all American forces by the end of next year is set in stone. Mr Obama long wanted to be able to say at the end of his presidency that he had ended the foreign wars in which America was engaged, and had brought all the troops home. However, the campaign against Islamic State in Iraq now makes it an impossible boast; that in turn weakens the political imperative of getting fully out of Afghanistan. Moreover, Ashton (“Ash”) Carter, Mr Obama’s new defence secretary, is reckoned to be more committed to ensuring a respectable denouement in Afghanistan than was his predecessor, Chuck Hagel. If Mr Carter thinks some troops should stay on, Mr Obama might find it hard to overrule him.

Yet in the end, foreign cash may prove more critical than foreign troops in sustaining a fragile government against an insurgency. Mr Obama promised to ask Congress, which Mr Ghani addressed on March 25th, to pay for the country’s 352,000 police and soldiers at least until the end of 2017. Mr Ghani was careful to thank not just American soldiers but also “the American taxpayer for his and her hard-earned dollars”.