WASHINGTON — At a White House meeting last winter, leaders of the F.B.I. and the Justice Department made an urgent appeal to John F. Kelly, the White House chief of staff, to side with them against Republicans in Congress who were pressing for information about the Russia investigation that would compromise confidential sources.

Mr. Kelly seemed to agree. But not long after Rod J. Rosenstein, the deputy attorney general, and Christopher A. Wray, the F.B.I. director, returned to their offices, Mr. Kelly called and reversed himself, according to a former law enforcement official. They would have to hand over the information after all.

What changed? Mr. Kelly’s answer: the president.

For more than a year, President Trump has been at war with law enforcement agencies that answer to him, interjecting himself into an investigation in which he himself is a subject. And he has escalated the conflict drastically in recent days by accusing the F.B.I. of placing a “spy” inside his 2016 campaign, pressuring the agencies to reveal secret information and demanding an investigation of his investigators.

The confrontation has no precedent in the modern era and holds great stakes not just for the president but for the relative autonomy for law enforcement investigations established after Watergate. Mr. Trump’s allies argue that he has every right to manage the executive branch and every reason to be outraged at possible misconduct aimed at his campaign. But many law enforcement veterans say he is wreaking untold damage on institutions that form the bulwark of a democratic society.