WASHINGTON—Attorney General William Barr said he would form a team to examine the origins of a 2016 counterintelligence investigation that conducted what he termed as “spying” on people affiliated with the Trump campaign, a characterization Democrats said was politically motivated and echoed the president’s longstanding criticism of the Justice Department’s Russia probe.

At a Senate hearing on Wednesday, Mr. Barr said the team would look at what lay behind the Federal Bureau of Investigation’s probe of the Trump campaign’s...