WASHINGTON—President Trump on Thursday said he agreed with Attorney General William Barr’s assertion that there was spying conducted on his 2016 campaign, a characterization that Democrats have criticized as being politically motivated.

What Mr. Barr said was “absolutely true,” said Mr. Trump. “There was spying in my campaign, and his answer was a very accurate one.”

Mr....