President Trump and Sen. Ted Cruz, R-Tex., had a contentious relationship during the Republican presidential primary in 2016, but the two could not have been more fond of one another at a campaign rally Monday evening.

Trump painted Cruz as a loyal supporter. Cruz opened up the rally, which drew tens of thousands of voters from across the state, telling Texans he is incredibly proud to have worked with the president to pass key parts of his agenda.

"On every issue, on taxes, I am proud to have worked hand in hand with President Trump to have passed the biggest tax cut in a generation," Cruz said.

[Byron York: In Texas, Trump and Cruz complete the transaction]

Trump flew to Houston Monday to stump for Cruz and other Republican candidates just under three weeks before voters head to the ballot box to elect their next Congress. All eyes have been on the Texas Senate race, featuring Cruz, the last man standing against Trump in the 2016 Republican primary, and Rep. Beto O'Rourke, D-Texas, that has won the hearts. minds, and pocketbooks of Democrats nationwide.

Monday's rally was not among the initial campaign stops the White House scheduled in August, but was announced Aug. 31 amid concerns that Cruz did not have the previously anticipated lock on the race.

The senator made a prediction Monday: "In 2020, Donald Trump will be overwhelmingly re-elected as president of the United States."

The president spent well over an hour lauding the senator and Republicans running for Congress in Texas, labeling Cruz one of his strongest, most steadfast allies in the Senate during his first two years in office.

"It got nasty and then it ended. I'll tell you what, nobody has helped me more with your tax cuts, with your regulation, with all of the things we are doing, including military and our vets, than Sen. Ted Cruz," Trump said. "Nobody. He defended your jobs, he defended your borders. ... He defends your families, he defends your faith, and we are defending together, with a lot of other Republicans, your freedom."

Shortly after leaving the stage, Trump tweeted out a video of Cruz speaking behind the presidential podium.

The change in rhetoric between the two men is striking, given the inflamed, often vitriolic exchanges the pair had while vying to become the 2016 Republican presidential candidate.

The president once insinuated in a tweet that his wife, first lady Melania Trump, was more attractive than the senator's wife, Heidi Cruz.

The tweet caused Cruz to call the president "a sniveling coward," and he warned Trump to "leave Heidi the hell alone."

Another of the worst episodes during the Republican primary was when the president alleged that Cruz's father was somehow involved in the assassination of former President John F. Kennedy.

"His father was with Lee Harvey Oswald prior to Oswald being, you know, shot," Trump said in a telephone interview. "I mean the whole thing is ridiculous. What is this? Right? Prior to his being shot. And nobody even brings it up. I mean, they don't even talk about that — that was reported. And nobody talks about it."

Cruz also notably refused to support Trump at the 2016 Republican National Convention, telling those present and watching to "vote their conscience." The senator's statement was met with resounding admonishment from the crowd.

Trump later said he would not accept Cruz's endorsement. But on Monday night, he was there in Houston to help Cruz across the finish line in his Senate race.