WASHINGTON—Long before he was tapped by President Trump to be attorney general, William Barr helped the Central Intelligence Agency navigate one of the most turbulent periods in its history.

Mr. Barr has said his work in the CIA in the 1970s—as an agency liaison to a skeptical Congress—was good preparation for his rise through the Justice Department ranks in the first Bush administration. Mr. Barr will again face a skeptical Congress as he leads a Justice Department going through its own turbulent trials.

The...