President Trump tangled on Twitter early Wednesdaywith retiring Sen. Jeff Flake (R-Ariz.), asserting that the Republican nominee to replace him had turned down Flake’s endorsement — a claim that Flake quickly disputed.

Trump’s post-midnight tweet came after Rep. Martha McSally (R-Ariz.) was declared the winner in a hard-fought GOP primary to replace Flake, a frequent Trump critic who decided not to seek reelection this year amid lackluster polling numbers.

“Martha McSally, running in the Arizona Primary for U.S. Senate, was endorsed by rejected Senator Jeff Flake....and turned it down - a first!” Trump wrote on Twitter. “Now Martha, a great U.S. Military fighter jet pilot and highly respected member of Congress, WINS BIG. Congratulations, and on to November!”

Without wasting much time, Flake replied to Trump on Twitter, saying his claim about an attempted endorsement was false.

“Sorry, @realDonaldTrump. I made no endorsement in this race,” Flake wrote. “I think the last endorsement I made was in the Alabama race.”

Flake’s tweet included a photo of a $100 check that he and his wife wrote to Doug Jones, the Democrat who prevailed in the Alabama special election, over Republican Roy Moore. Moore, who was backed by Trump, faced accusations of pursuing teenage girls when he was in his 30s.

Rep. Martha McSally (R-Ariz.) won Arizona’s GOP Senate nomination on Aug. 28 and will face Rep. Kyrsten Cinema (D) in November.

The memo line in Flake’s check to Jones read: “Country over Party.”

Trump, who made no official endorsement in the Arizona Senate primary, has repeatedly denigrated Flake in the past, calling him a “flake” on Twitter in June.

Flake stoked speculation about a 2020 challenge to Trump in March, when he traveled to New Hampshire, the nation’s first primary state, to deliver an address to a crowd of business leaders and political activists. In his speech, he decried the “degradation of the United States and her values” by the current occupant of the White House.

In a tweet later Wednesday morning, Trump offered his “total and complete Endorsement” in the Arizona race to McSally, calling her “an extraordinary woman” whose agenda aligns with his.

In a tweet later Wednesday, Flake congratulated both McSally and Rep. Kyrsten Sinema, the Democratic nominee.

“Whether it’s a Democrat or a Republican representing Arizona, it’s going to be the first female senator in Arizona’s history,” Flake said subsequently on MSNBC. “That’s a wonderful thing. We all ought to celebrate that. . . . I hope that we can get away from the vitriol that usually accompanies these kinds of contests and celebrate the fact that we’re going to have a change. . . . I wish them both well.”

Felicia Sonmez contributed to this report.