It was payback.

Ted Cruz said Thursday that he refused to endorse Donald Trump at the GOP convention because he trashed the Texas senator’s family during their nasty primary battle.

During the vicious contest, Trump re-tweeted an unflattering picture of Cruz’s wife, Heidi Cruz, and even suggested that the senator’s dad was somehow involved in President John F. Kennedy’s 1963 assassination.

Speaking at a Texas delegation breakfast on Thursday, a party activist reminded Cruz he signed a pledge to back the GOP presidential nominee.

“And I’ll tell you the day that pledge was abrogated. The day that was abrogated was the day this became personal,” Cruz said.

“I am not in the habit of supporting people who attack my wife and attack my father. And that pledge was not a blanket commitment that if you go and slander and attack Heidi, that I’m going to nonetheless come like a servile puppy dog and say, ‘Thank you very much for maligning my wife and maligning my father.’ ”

At least one person in the audience said Cruz should look beyond insults on the campaign trail and shouted at him: “This is politics.”

Cruz shot back, “This is not politics! I will tell the truth!,” winning applause.

“I will not malign, I will not insult, I will not attack, I will tell the truth. This is not a game. It is not politics — right and wrong matters,” he said. “We have not abandoned who we are in this country. No, sir, I do not believe that is correct.”

Cruz stunned convention-goers Wednesday night with a prime-time address that fell well short of endorsing the nominee.

He drew a building full of boos — led by New York delegates sitting up front — when he told delegates to “vote their conscience.”

Cruz said Thursday that he gave Trump’s team the controversial remarks in advance and spoke directly to The Donald this week, saying no endorsement was coming.

“They saw my speech several hours before I gave it. They knew exactly what I was going to say,” Cruz said at Thursday’s breakfast meeting.

“I assume the reason they wanted me to speak is they believed my delivering that message would encourage people to come out and vote, and they believed it would help.”

Cruz said he will not be voting for Democrat Hillary Clinton under any circumstances — without explaining who he would support.

“I am doing what millions of Americans are doing. I am watching, I’m listening,” he said. “I can tell you I’m not voting for Hillary.”

The Texas senator also told followers not to write in his name on any ballots: “I am not a candidate in this race.”

The fight between Cruz and Trump is personal and nasty – even among their surrogates.

Moments after Cruz’s speech on Wednesday, New Jersey Gov. Chris Christie eagerly found TV cameras to denounce him.

Cruz campaign manager Jeff Roe responded Thursday, questioning the governor’s manhood. Christie was the first one-time rival of Trump’s to endorse him.

“That guy turned over his political testicles long ago,” Roe told the Chris Stigall radio show. “I don’t take what he has to say with any meaning. You know, he embarrassed himself pretty quickly in this.”

Republicans were still fuming Thursday morning about Cruz’s remarkable diss, as GOP stalwarts rushed to morning airwaves to bash him.

“If a convention’s goal is to unite your party behind one candidate, Sen. Cruz didn’t get the memo,” former Texas Gov. Rick Perry told CNN.” “I thought it was a bad call.”

Although Perry had been one of the first Republicans to blast Trump early in the primary season, he’s now a full-throated backer. He predicted that Texans won’t forget Cruz turning his back on the party’s nominee.

“I don’t have to go back to Texas and explain why I was part of the problem and not part of the solution,” Perry added.

Former RNC chair Haley Barbour said Cruz’s speech was a losing gamble for 2020, the year of the next presidential campaign.

“Last night was a political calculation by Sen. Cruz and how to help himself in 2020,” Barbour told MSNBC.

The former GOP chief tried holding off on blasting Cruz but then blurted out: “I sort of think it’ll backfire on him.”

Eric Trump, the candidate’s son, called Cruz’s speech “classless.”

“How do you get booed out of your own convention, by your own party, by your own delegation,” he asked on CBS “I thought it was classless.”

Brother Donald Trump Jr. said Cruz was cynically looking forward to 2020 – when he should have been focused on 2024.

“Ted is thinking about, ‘You know what? If Hillary Clinton gets this, I can run again in four years as opposed to waiting for eight,’ when my father would finish up his second term. It’s pure showmanship,” Trump Jr. told CNN. “It’s total disloyalty.”

Trump campaign chairman Paul Manafort said the ticket is in better shape thanks to Cruz’s bomb throwing.

“The party is unified. Last night, despite what Sen. Cruz did, the party came together,” he told NBC.

“Cruz used very bad judgement, I think he made a mistake. I think he was not respectful to the invitation to the convention to come to speak. He understood what the responsibilities are of somebody in his position and he didn’t meet them.”

Cruz’s speech upstaged a well-received address by Trump’s running mate, Indiana Gov. Mike Pence.

The GOP evening ended oddly as Trump approached Pence and gave him an awkward air kiss — instead of the traditional presidential unity embrace, or grabbing the running mate’s hand and hoisting it skyward.