WASHINGTON — When President Trump learned that the Justice Department was dropping a case against a former F.B.I. official whom he considered one of his longtime enemies, his immediate response was anger. As he flipped on the television Friday and watched how the story was being covered, that anger only mounted.

Since taking office, Mr. Trump has searched for an attorney general who would function much as Roy Cohn did for him as his personal lawyer and fixer in the 1970s — a warrior committed to protecting him and going after his foes. The president thought he had found that person in William P. Barr. But now, people close to Mr. Trump say, he is not so sure.

The president was cheered this week when Mr. Barr moved to reduce the sentence of a convicted presidential friend, only to be shocked when the attorney general publicly called on Mr. Trump to stop tweeting about it. And after his livid reaction to the Justice Department’s decision to drop a separate case, which he heard about without any advance notice, he learned that Mr. Barr was intervening more favorably on behalf of another presidential ally.

The whipsaw events of recent days have bewildered much of Washington, including some of the people around the president and his attorney general. Once seen as a lock step partnership, it now may be the most complicated relationship in town. The six blocks between the White House and the Robert F. Kennedy Department of Justice Building have become a political buffer zone and no one can be entirely sure what comes next.