Afghan officials have pleaded with three American presidents to reconsider their support for Pakistan, which was both receiving billions of dollars in American aid and harboring the leaders of a Taliban insurgency that the United States has struggled to defeat.

But when President Trump suspended nearly all American security aid to Pakistan on Thursday for what he called the country’s “lies and deceit,” any jubilation in the halls of power in Afghanistan — and there was some — was leavened with worry over how the move might affect a complex war that has pushed the Afghan government to the brink.

If there is one consensus among Afghan leaders and their American counterparts, it is that dealing with Pakistan is both vital and difficult.

American and Afghan officials accuse Pakistan’s powerful military intelligence service of maintaining influence with the Taliban and the group’s most ascendant faction, the Haqqani network, which is behind many of the large-scale attacks on Afghan cities. Through those links, Pakistan has the ability to control at least some of the tempo of the fighting in Afghanistan — and it has done little to constrain it over the past two years, the officials say.