Sen. Thom Tillis (R-N.C.) at a Judiciary Committee hearing last month. (Aaron P. Bernstein/Reuters)

President Trump on Tuesday endorsed Sen. Thom Tillis, giving a boost to the North Carolina Republican, who has drawn scorn from the right for at times parting ways with the president.

“Senator Thom Tillis of North Carolina has really stepped up to the plate,” Trump tweeted Tuesday night. “Thom is tough on Crime, Strong on the Border and fights hard against Illegal Immigration. He loves our Military, our Vets and our great Second Amendment. I give Thom my Full and Total Endorsement!”

Tillis is facing two Republican primary challengers: Garland S. Tucker III, chief executive of a Raleigh investment company, and farmer Sandy Smith. On the Democratic side, Cal Cunningham, a veteran and former state senator courted by national Democrats, recently announced his candidacy.

Tillis, North Carolina’s former state House speaker, ousted Sen. Kay Hagan (D) in 2014. During that year’s Republican primary, Tillis bested several tea party challengers to win the nomination in what was viewed as a major victory for the GOP’s establishment wing.

But Tillis has recently drawn criticism from some of the president’s supporters for opposing parts of his agenda.

As the White House and congressional Democrats sparred in February over funding for Trump’s long-promised border wall, Tillis wrote a Washington Post op-ed announcing that he would vote in favor of a resolution disapproving of Trump’s declaration of a national emergency on the issue.

But then, when the day of the vote came, Tillis reversed course and voted against the resolution, citing his conversations with Vice President Pence and other Republicans as influencing his decision to side with Trump.

Last month, Rep. Mark Meadows (R-N.C.), one of Trump’s closest allies on Capitol Hill, notably declined to endorse Tillis, saying in an interview with The Post that Tillis had “not asked me” to back him.

“I doubt that I would give a congressional endorsement to any senator, that it would matter,” Meadows said.

On Tuesday, the North Carolina Democratic Party responded to the news of Trump’s endorsement by saying that Tillis had “spent the past few months spinelessly bending over backwards to appease President Trump at the cost of North Carolina families.”

“It’s no wonder he’s Trump’s handpicked candidate — he’s abandoned the state he represents for the president he thinks he needs,” the party’s spokesman, Robert Howard, said in a statement.