They have to get married — so they can get divorced.

Both the celebrity hairdresser who alleges his heiress “wife” faked their lavish wedding and the ex are now seeking to get their union legalized so they can get down to the nitty-gritty: a potential financial settlement and the official end to their union.

As first reported by The Post on Saturday, hair-snipper-to-the-stars William Jordan Blackmore filed suit in Brooklyn federal court claiming that auto-sales scion Andi Potamkin secretly staged their $1 million 2015 Utah desert nuptials as a PR “stunt.’’ He said he only found out they never legally tied the knot when she broke it off with him last year.

A lawyer for Potamkin — whose millionaire family founded the Potamkin Auto Group — insisted Sunday that Blackmore was aware he and Andi would need to go to the courthouse to make their marriage legal after the lavish ceremony officiated by their yoga instructor. But the couple never did.

Regardless, both sides say they recently filed papers in Utah to get their 2015 “wedding” recognized as a legal one amid their prenup battle.

“Both parties agree that they had a beautiful destination wedding, that they were very much in love, and that they lived together as husband and wife,” said Potamkin’s lawyer, Jennifer Altman.

“Indeed, both parties have filed to recognize the marriage in the state of Utah. There is a prenuptial agreement that sets forth the terms under which the assets will be distributed upon divorce.”

In his New York suit, Blackmore — who lived with Potamkin in Brooklyn — is seeking $2 million in damages and to have the prenup declared not binding.

His lawyer wouldn’t explain what the strategy was behind claiming the marriage was valid but the pre-nup was not.

Blackmore claims that while he believed they’d been legally wed in the celeb-studded, four-day 2015 event that featured an exchange of rings and vows, his “wife” had secretly told the yoga instructor she didn’t need to get ordained because they would get hitched legally in New York beforehand.

The ceremony appeared totally aboveboard, he said.

But after she broke off the relationship in December, he says, Potamkin presented him with a draft separation agreement in January asking him to agree that their “symbolic ceremony … did not constitute a legally binding marriage.”

His attorney says it’s inconsistent that Potamkin is now seeking to validate the union.

“Andi Potamkin’s current change of position is all too convenient an effort to distance herself from the fraud,” said lawyer Matthew Coogan.

Additional reporting by Kathianne Boniello