Washington (CNN) Up for a second Senate term in Texas this year, "Lyin' Ted" Cruz, as President Donald Trump nicknamed him, is suddenly Trump's biggest fan.

Faced with a potentially tough re-election battle against Democratic Rep. Beto O'Rourke , Cruz has used recent public appearances -- including a speech at the Conservative Political Action Conference on Thursday -- to embrace Trump, stake out hard-line positions in debates over gun control and immigration, and antagonize Democrats.

On Thursday, he even invoked "The Simpsons."

"The Democrats are the party of Lisa Simpson," Cruz said of the know-it-all character. "And Republicans are happily the party of Homer, Bart, Maggie and Marge."

Cruz's moves underscore his view of the upcoming midterm elections as a duel of the party's bases -- and whichever turns out more of its voters wins.

That means turning out Trump's supporters.

The senator Trump had once called "Lyin' Ted" on Thursday heaped praise on the President's first year in office.

"On substance, the record of delivering has been remarkable," he said.

He also embraced Trump's opposition to stricter gun laws, accusing Democrats of politicizing the issue after the mass shooting last week at a high school in Parkland, Florida -- as well as the President's call to arm teachers.

"Every time you see a horrific crime, people in the media and Democratic politicians immediately try to leap on it to advance their agenda, and their agenda is stripping Second Amendment rights from law-abiding citizens," Cruz said, adding that confiscating guns is "where they want to end up."

"I think it makes perfect sense that if teachers want to exercise their right to keep and bear arms, it will only make schools safer," he said.

It all sounds like something of a 180-degree turn for Cruz, who used his speech at the 2016 Republican National Convention to urge Americans to vote their consciences -- effectively extending permission to break with the party's presidential nominee.

Cruz has had Trump's back outside the Washington area as well.

In Dallas last weekend, Cruz aligned himself with Trump on special counsel Robert Mueller's Russia investigation, saying investigators had found no evidence of collusion, an inaccurate claim with the investigation still underway.

"On the face of these indictments, they say that the American side of it was unwitting -- that there was not collusion. That's pretty significant," he told reporters.

Cruz has also staked out ground to the right of Trump on some issues.

He pleased immigration hard-liners this month by casting the Senate's lone vote against opening a debate on three competing bills that would give "Dreamers" a path to legal status, all of which were voted down.

Cruz's moves could even come at the risk of his future presidential prospects: He angered Iowa Republicans by blocking Iowa Agriculture Secretary Bill Northey for a federal agriculture post, citing ethanol regulations that he says harm oil refineries.

The Iowa Republican Party's central committee approved a resolution urging Cruz to withdraw his hold on Northey's nomination. State GOP chairman Jeff Kaufmann sent Cruz a letter warning that should he "wish to remain in good standing with Iowa Republicans," he must release his hold on Northey and "end the political points he is attempting to gain in an election year."