After enthusiastically endorsing an Alabama senator’s campaign for re-election, President Trump distanced himself on Tuesday night from the candidate’s loss in the most Trumpian way possible: He deleted his supportive tweets.

Hours after Senator Luther Strange, a Republican from Alabama, lost in Tuesday’s primary runoff, Mr. Trump excised at least three favorable Twitter posts, including one sent Tuesday morning. In that tweet, posted as the polls in Alabama opened, the president boasted that Mr. Strange “has been shooting up in the Alabama polls since my endorsement.”

Mr. Strange, who was appointed to the Senate early this year after Jeff Sessions vacated his seat to become attorney general under Mr. Trump, conceded on Tuesday night to Roy S. Moore, a former Alabama Supreme Court justice whose candidacy was opposed by leading establishment Republicans.

The deleted tweets were archived by ProPublica, a nonprofit journalism website, but are no longer public on Twitter, feeding into an intriguing legal debate about whether Mr. Trump is breaking the law when he expunges his tweets.