Conor McGregor says he's done fighting. (John Locher, File)

Conor McGregor, one of the most marketable names in mixed martial arts and a former UFC champion in two weight classes, announced his retirement in the wee hours of Tuesday morning via his Twitter account.

McGregor has fought sparingly in the octagon in recent years. His most recent bout, an October submission loss to Khabib Nurmagomedov at UFC 229, was marred by post-bout melees involving both fighters and their entourages. As a result, the Nevada State Athletic Commission suspended Nurmagomedov for nine months and McGregor for six, a sanction that was scheduled to end April 6.

That UFC 229 card drew 2.4 million pay-per-view buys, the most ever for an MMA event. In August 2017, McGregor fought in a heavily hyped boxing match against undefeated champion Floyd Mayweather Jr., which drew 4.3 million pay-per-view buys in North America alone and earned McGregor a reported payday of more than $100 million.

UFC President Dana White told the Associated Press in a text message that McGregor’s net worth was a big reason for the announcement, which he said “totally makes sense.”

“He has the money to retire, and his whiskey is KILLIN it,” White said, a reference to his Proper No. Twelve Whiskey venture. “If I was him, I would retire too. He’s retiring from fighting. Not from working. The Whiskey will keep him busy, and I’m sure he has other things he’s working on. He has been so fun to watch!!! He has accomplished incredible things in this sport. I am so happy for him and I look forward to seeing him be as successful outside of the octagon as he was in it.”

Despite awful reviews -- one said McGregor’s Irish whiskey featured “notes of turpentine interlaced with the musk from a crowded, poorly-maintained Turkish bathhouse sauna" -- the liquor reportedly has sold well since its debut in September. White predicted last year that McGregor would make “a billion dollars” off Proper No. Twelve.

Hours before his announcement, McGregor appeared on “The Tonight Show” and said he was negotiating to fight at UFC 239 in July (Donald “Cowboy” Cerrone was one rumored opponent) ahead of a possible rematch with Nurmagomedov late this year. But he also reiterated that he didn’t necessarily need to step back into the octagon.

“I don’t necessarily need to fight,” McGregor said on the show, per the AP. “I am set for life. My family is set for life. We are good, but I am eager to fight, so we’ll see what happens.”

McGregor has had a few run-ins with the law in the United States. The seeds of the Nurmagomedov brawl were planted four months earlier when he threw an equipment dolly at a bus carrying the Russian fighter and his training partners during a UFC promotional event in Brooklyn. McGregor pleaded no contest to a count of disorderly conduct and received community service and anger-management courses.

Earlier this month, McGregor was charged with strong-arm robbery and criminal mischief, both felonies, in Miami after police alleged that the Irishman “stomped” on and took a man’s cellphone in an incident outside the Fontainebleau Hotel.

It’s not the first time McGregor, 30, has announced his retirement on Twitter. In April 2016, he wrote that he had “decided to retire young,” one month after a loss to Nate Diaz. But he reversed his decision two days later would return four months after that with a victory over Diaz at UFC 202. He then won the UFC lightweight title by beating Eddie Alvarez at UFC 205 in November 2016, his final victory in the octagon.

Former MMA star Ronda Rousey seemed to suggest there might be another reversal in McGregor’s future.

“Well, it’s a creative way to retire and it’s a cryptic way to retire so we’ll see how permanent it is,” she said on ESPN Tuesday morning. “If he wants to retire forever, he’s more than earned it.”

McGregor finishes with a professional MMA record of 21-4 and a boxing record of 0-1.

Read more from The Post:

Yale rescinds admission of student linked to scandal involving soccer coach

UC Irvine coach apologizes for using ‘Queen’ taunt to rattle Oregon player

There’s only one perfect NCAA tournament bracket left. It probably isn’t yours.

The Sweet 16 is set, and boy is it top-heavy