Republican presidential candidate Ted Cruz has been complimenting one of his 2016 rivals, businessman Donald Trump, for months. Now, Trump is warming up to Cruz, too. Here's what the two men have had to say about one another on the political trail. (The Washington Post)

In the world of politics, this summer’s odd-couple buddy movie stars Donald Trump and Sen. Ted Cruz (R-Tex.).

The script goes something like this: Two men are rivals for the Republican presidential nomination — but one pursues the other until the pair strike up an unlikely friendship.

Next week, Cruz will headline a Capitol Hill rally Wednesday to protest the Iranian nuclear deal, an event he has helped organize. The entire GOP field opposes the deal, but Trump is the only one who got a personal invitation from Cruz to appear, and the two are currently the only presidential candidates set to attend.

It is not news anymore when one presidential candidate calls another “incompetent.” Or an “idiot.” Or a “jackass.” But a budding primary season bromance is far rarer.

The crowded field of 17 GOP candidates may be playing a part in the unfolding dynamic between the two. “This time around, given how many candidates there are, it’s almost like they’re making ‘Survivor’-type pacts with other candidates that will live for a while until they outlive their usefulness,” said Andrew E. Smith, a professor of political science at the University of New Hampshire.

And if anyone would be familiar with the tropes of reality TV, it is Trump.

“I like Donald Trump. He’s a friend of mine. I’m grateful that he’s in the race,” Cruz said last week.

William Mayer, a professor of political science at Northeastern University, said he “can’t think of any precedent” where two presidential candidates from the same party have joined forces and invited one another to events, as Cruz has already done twice to Trump.

During the 2000 election, Sen. John McCain (R-Ariz.) and Bill Bradley (D) held a joint appearance where they called for campaign finance reform. But “within the same party, it’s not something you see,” Smith said.

The Iran deal isn’t the only issue where Cruz says The Donald has given the senator’s own campaign a boost. Cruz has also said Trump’s focus on immigration has helped — the Cruz campaign.

“Donald Trump talking about this issue makes the media talk about that and that has resulted in incredible support for our campaign,” Cruz told WYFF (Channel 4) after campaigning in Greer, S.C., on Friday.

And Cruz is grateful for the boost. Candidates who have chosen to “slap Donald Trump with a stick” are “foolish,” Cruz told WMUR (Channel 9) on Monday in New Hampshire. “Not only have I refused to do so, but I have been very consistent in praising Donald Trump and praising the people who are coming out to see him,” Cruz said, in what appeared to be a jab at longtime Cruz nemesis McCain, who had called people who showed up to a Trump rally “crazies.”

According to people close to the Trump campaign, the relationship has been driven almost entirely by Cruz. The Texas senator has sought Trump out on numerous occasions, both before and after the mogul jumped into the 2016 race.

Earlier this year, Trump knocked Cruz for being born in Canada and said it was unclear whether that made him ineligible to run for president. Legal experts have said Cruz meets the citizenship threshold necessary to be president.

“He was born in Canada, if you know, and when we all studied our history lessons, you’re supposed to be born in this country, so I just don’t know how the courts would rule on it,” Trump said. “But it’s an additional hurdle that he has that no one else seems to have.”

That comment did not seem to dissuade Cruz. Early in the summer, Trump seemed a bit befuddled by Cruz’s attention, saying of a July meeting between the two, “I don’t know why I’m meeting him, to be honest, but I do have respect for him.”

Meanwhile, Cruz has gone out of his way to praise Trump.

Trump’s controversial remarks about Mexican immigrants early in his campaign led Macy’s and Univision to sever ties with him. He had few defenders — but one of them was Cruz, who called the businessman “bold” and “brash.”

“I salute Donald Trump for focusing on the need to address illegal immigration,” Cruz said on NBC’s “Meet the Press.”

After Cruz’s vocal summer defense, his long-sought meeting with the mogul finally took place at Trump Tower in New York.

The men talked for 45 minutes, discussing the presidential race, trade and immigration. Cruz invited Trump to tour the U.S.-Mexico border, a trip Cruz eventually had to miss because of Senate votes. Trump did make a whirlwind visit to the border.

Trump has welcomed the exchanges and meetings, his people said, but he does not see them as especially necessary or helpful to him. Instead, he views Cruz as a useful, friendly face who appreciates him and whom he is happy to be chummy with on debate stages.

One Trump associate, who requested anonymity, said the candidate has privately noted that Cruz seems to be angling for his endorsement or at least votes from Trump’s bloc, should Trump end his campaign in the coming months. But Trump has also said that Cruz may be overthinking his playbook, since the tycoon has no intention of leaving, the associate said.

If the Cruz-Trump friendship is one of convenience, it may be a lot more convenient for Cruz. While Trump has been riding high in the polls, Cruz has been stuck in the middle of the pack, despite a small bump in his national numbers following the Aug. 6 Republican debate. Last month, Cruz announced a crusade to defund Planned Parenthood and took a weeklong bus tour across the South.

Aligning with Trump is a double-barreled advantage for Cruz: It affords him a huge spotlight — and the opportunity to use that attention to establish himself as a second-choice pick for the real estate mogul’s supporters and broaden the senator’s support beyond his current conservative and evangelical base.

“We want an opportunity to win over the new people who Trump brought into the race,” a Cruz adviser said. “It brings a lot of people who have never heard of Ted Cruz.”

Cruz may run the risk that his bet backfires, Mayer said.

“It could be dangerous in the long run in the sense if you look at all the polling data on Trump it’s very clear that a whole lot of people dislike him,” Mayer said.

But right now, they are paying attention. And Cruz’s campaign thinks they’ve made a solid bet.

“You can ride the wave that comes or you can dive under it. But you have to recognize the wave is coming and get on top of it,” a Cruz adviser said of the Trump phenomenon. “I think we’re on the wave and everybody else went, ‘Wow, why did I dive under that? Look at Ted Cruz go.’ ”

Cruz has attempted to paint himself as an insurgent insider — a former Supreme Court clerk, former George W. Bush administration official and senator from one of the nation’s largest states but one who loves taking on both Democrats and Republicans. Both he and Trump are proud of their reputations as bold, brash outsiders disliked by the establishment.

One of the things Cruz seems to admire most about Trump is an attribute he has been noted for: the willingness to say and do the things many politicians avoid for fear of offending others.

This is not a worry either man seems to struggle with.

Trump has branded dozens of people “losers” and “morons.” Cruz assailed congressional leadership in his recent book and called Senate Majority Leader Mitch McConnell (R-Ky.) a liar on the chamber’s floor in July.

But while Cruz has largely steered clear of attacking his fellow GOP contenders, Trump has taken swipes at most of the field — early, often and with great relish.

In New Hampshire last month, Trump dismissed former Florida governor Jeb Bush as “low energy,” an “unhappy person” — and boring to boot. “He’s weak on immigration. He’s in favor of Common Core. How the hell can you vote for this guy?” Trump asked.

Trump has told Sen. Rand Paul (Ky.) he should drop out of the presidential race, said Carly Fiorina did a “terrible job” running Hewlett-Packard and had given out Sen. Lindsey O. Graham’s phone number and branded the South Carolina politician a “lightweight” and an “idiot” after Graham called Trump a “jackass.”

Of the race’s top tier, the only two rivals who have been spared his scorn are the pair he mentioned as potential running mates when NH1 asked last month: retired neurosurgeon Ben Carson — and the Texas senator.

“I like Ted Cruz,” he said.

Robert Costa contributed to this report.