Sen. Ted Cruz, R-Texas, is endorsing Donald Trump’s presidential campaign, the latest chapter in a rocky relationship between the two men that has ricocheted from fawning expressions of support to searing personal insults to, now, a kind of detente.

In a Facebook message posted Friday, Cruz said he has had “areas of significant disagreement” with Trump, but cannot allow Hillary Clinton to become president.

“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, noting he is honoring a commitment he made to endorse the Republican nominee – something he stepped back from earlier this year.

The decision marks a politically risky move for Cruz, who pointedly refused to endorse Trump during a prime-time speech at the Republican National Convention in July. Cruz exhorted Republicans to “vote your conscience” and said he was standing on truth and principle – ideologically pure stances Cruz espoused during his campaign and that could be imperiled with his endorsement of Trump.

Cruz was booed off the stage and his wife was was filmed leaving early to avoid angry delegates. At a tense breakfast with the Texas delegation the following morning, Cruz said he wasn’t going to “act like a servile puppy dog” and back Trump.

“No, this is not politics,” Cruz said at the time. “I will tell the truth.”

The truth, Cruz said, was that Trump had personally attacked his wife, Heidi, and father, Rafael. The Republican presidential nominee repeatedly accused Rafael Cruz, who was born and raised in Cuba, of associating with Lee Harvey Oswald around the time of John F. Kennedy’s assassination. Trump also retweeted an unflattering photo of Heidi Cruz contrasted with a photo of Trump’s wife Melania, a retired model.

“I am not in the habit of supporting people who attack my wife and attack my father,” Cruz said in July. Previously, he said Trump was a “sniveling coward” who should “leave Heidi the hell alone.”

In July, delegates questioned how Cruz could turn back on a pledge he and other candidates made to support the Republican nominee.

“The day that was abrogated was the day this became personal,” he said. But even in July, Cruz’s aides didn’t rule out the possibility of an endorsement at a later date.

Trump said after the convention he would not accept Cruz’s endorsement if it were offered. In a statement Friday, Trump also reversed himself.

“I am greatly honored by the endorsement of Senator Cruz,” the statement said. “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.”

The relationship between Cruz turned vicious after Trump said Cruz’s Canadian birthplace was a “very precarious” issue for the Republican Party and questioned his eligibility to run for president. Cruz has long said that he qualifies as a natural-born citizen because his mother was born in Delaware. The two men spent months lobbing pointed insults at one another. Cruz called calling Trump a “pathological liar” who is “utterly amoral,” a “serial philanderer,” a “bully” and a “A narcissist at a level I don’t think this country has ever seen.”

Trump unloaded on Cruz for months, yoking him with the nickname “Lyin’ Ted.” Trump called Cruz a “nasty guy,” an “anchor baby,” “unstable” and “sick.”

It wasn’t always this way.

At the beginning of the presidential race, the two men enjoyed a relationship that was unusually cozy for two ostensible rivals for the Republican presidential nomination – a political buddy comedy movie of sorts. Cruz repeatedly lauded Trump as “terrific” and said he was happy the real estate mogul was in the presidential race. Cruz spent an afternoon at Trump Tower, and the two men headlined a Capitol Hill rally against the Iranian nuclear deal – something virtually unheard of for two candidates running against one another.

In December, Cruz promised that nothing would come between him and Trump.