John Boehner. AP Former House Speaker John Boehner ripped into Sen. Ted Cruz in a memorable fashion during a Wednesday appearance, prompting Cruz to say that he "doesn't know" Boehner.

"I have Democrat friends and Republican friends. I get along with almost everyone, but I have never worked with a more miserable son of a b---- in my life," Boehner said, dubbing Cruz "Lucifer in the flesh."

But a closer look at their history reveals that the two weren't always enemies. In fact, long before Boehner saw Cruz as Lucifer, the 2016 Republican presidential candidate was actually his lawyer.

It was 1998, more than a decade before Boehner became speaker and Cruz was elected to the Senate. Boehner had just sued Rep. Jim McDermott (D-Washington) for allegedly breaking wiretapping laws, according to The Washington Post.

That lawsuit stemmed from a Florida couple recording a call between Boehner and then House Speaker Newt Gingrich that they heard on a police scanner. They sent the call to McDermott, who later allegedly released it to The New York Times and other publications. The call centered around ethical violations Gingrich faced at the time, and McDermott was the top Democrat on the House Ethics Committee, according to The Post.

US Republican presidential candidate Ted Cruz at the Iowa Faith & Freedom Coalition Forum in Des Moines. Thomson Reuters

Furious, Boehner called it an invasion of privacy. He hired Cruz, who had recently served as a clerk for then Chief Justice William Rehnquist. The then 27-year-old Cruz made an early appearance in the press defending his client after Boehner sent out a fundraising appeal to help pay for his legal defense.

"The fund-raising letter is much ado about nothing," Cruz told The Seattle Times. "Congressman McDermott has consistently attempted to delay the litigation and drive up the expense. It is reasonably expected that Congressman Boehner will use the means at his disposal to raise the funds to pursue this lawsuit."

Cruz wouldn't end up working Boehner's case for long, though, and there wasn't a ruling in the case until 2004, when a federal judge sided with the Ohio congressman. Boehner ended up being awarded more than $1 million in legal fees.

Boehner was asked about the whole ordeal by Jay Leno on "The Tonight Show" last year, when he called his old legal pal a "good guy," The Post reported.

"I don't always agree with him, but he's a good guy," he said.