Sen. Ted Cruz announced Friday that he will vote for ex-primary foe Donald Trump in November and urged others to do the same, reversing course to back the Republican nominee two months after he stunned the party brass by withholding his endorsement at the Cleveland convention.

Cruz and Trump were bitter rivals in the final stretch of the primary campaign. The Texas senator’s announcement of support, made on Facebook, comes just days before the first debate between Trump and Hillary Clinton.

“Like many other voters, I have struggled to determine the right course of action in this general election,” Cruz said in his statement.

Noting that he urged voters in Cleveland to vote their “conscience,” he said: “After many months of careful consideration, of prayer and searching my own conscience, I have decided that on Election Day, I will vote for the Republican nominee, Donald Trump.”

Cruz said he made the decision because he wants to keep his word to support the Republican nominee – and he finds Hillary Clinton “wholly unacceptable.”

“Our country is in crisis. Hillary Clinton is manifestly unfit to be president, and her policies would harm millions of Americans. And Donald Trump is the only thing standing in her way,” he said. “A year ago, I pledged to endorse the Republican nominee, and I am honoring that commitment. And if you don’t want to see a Hillary Clinton presidency, I encourage you to vote for him.”

Trump released a statement saying he was honored: “I am greatly honored by the endorsement of Senator Cruz. We have fought the battle and he was a tough and brilliant opponent. I look forward to working with him for many years to come in order to make America great again.”

Yet Cruz's support was by no means a foregone conclusion.

After Cruz snubbed Trump at the Republican convention in July by declining to outright endorse him during his remarks, Trump blasted Cruz on the way out, saying he didn’t even want his endorsement.

The convention capped a personal and nasty primary battle.

During that contest, Cruz called Trump a "pathological liar" and "utterly amoral." After Trump retweeted an unflattering picture of Cruz's wife Heidi, Cruz called Trump a "sniveling coward."

"This man is a pathological liar. He doesn't know the difference between truth and lies. He lies practically every word that comes out of his mouth," Cruz said in May.



Trump, for his part, frequently referred to Cruz as "Lyin' Ted" and in May implied that Cruz's father Rafael helped President John F. Kennedy's assassin Lee Harvey Oswald.

"His father was with Lee Harvey Oswald prior to Oswald's being — you know, shot. I mean, the whole thing is ridiculous,” Trump said in an interview with Fox News. “What is this, right prior to his being shot, and nobody even brings it up. They don't even talk about that. That was reported, and nobody talks about it.”

Moving beyond their many feuds, Cruz on Friday cited several factors -- including the Supreme Court vacancy. "We know, without a doubt, that every Clinton appointee would be a left-wing ideologue. Trump, in contrast, has promised to appoint justices 'in the mold of Scalia,'" he said.

Cruz also praised Trump for releasing an updated list of potential Supreme Court nominees that includes Sen. Mike Lee. Cruz said he had sought "greater specificity on this issue, and today the Trump campaign provided that."

The Associated Press contributed to this report.