WASHINGTON — The Trump administration announced on Thursday that it would suspend nearly all security aid to Pakistan, an across-the-board freeze that is the most tangible sign yet of Washington’s frustration with the country’s refusal to crack down on terrorist networks operating there.

The decision, which could affect as much as $1.3 billion in annual aid, came three days after President Trump complained on Twitter that Pakistan had “given us nothing but lies & deceit” and accused it of providing “safe haven to the terrorists we hunt in Afghanistan.”

The move underlines how swiftly relations with Pakistan have deteriorated since Mr. Trump took office. But it echoes several previous rifts between the countries over Pakistan’s role as a sanctuary for extremist groups — a role that has poisoned Islamabad’s relations with Washington since the terrorist attacks of September 2001.

Administration officials emphasized that the freeze was temporary and could be lifted if Pakistan changed its behavior. The United States is urging the Pakistani government to cut off contact with militants and reassign intelligence agents with links to extremists, among other measures.