WASHINGTON—President Donald Trump has spent months chastising Jeff Sessions, questioning why his attorney general wasn’t investigating Hillary Clinton, criticizing his recusal from an investigation into Russia’s meddling in the 2016 campaign, describing him as “beleaguered,” and once misspelling his name in a tweet.

Mr. Sessions didn’t respond publicly to the insults, instead praising his boss. But on Wednesday, the attorney general rebutted Mr. Trump after the president scolded him for his decision to refer a probe of the...