Former Shark Tank star Robert Herjavec will pay ex-wife Diane Plese $125,000 a month in support and a total of $25 million from his massive fortune, an Ontario Superior Court judge has ruled.

Herjavec, 56, an entrepreneur and also a participant on Dancing With The Stars, and Plese, his wife of 24 years, fought their family law court battle over everything from the number of parking spaces — seven to 10 — inside the garage of their 22,500-sq.-ft. Bridle Path-area mansion to the value of their other pricy real estate assets, the judgment stated.

Plese, 56, already had $20 million in assets from the marriage. Justice Ruth Mesbur ordered Herjavec to pay her an additional $2.6 million in equalization payment. The ex-wife will also receive another $2.4 million once the couple’s Florida property is sold, the judgment stated.

The ex-wife will also reap one-third of the proceeds of the family’s Caledon ski chalet — roughly another $400,000, providing her with just over $25 million.

Herjavec was “involved in an extramarital affair” with another woman in 2014 before he met his current wife, Kym Johnson. She was his dance partner on Dancing With the Stars, wrote Mesbur in her judgment released last month.

Robert Herjavec is pictured with his current wife, Kym Johnson, are pictured in September, 2016, at the Creative Arts Emmy Awards at the Microsoft Theater in Los Angeles. (AP photo)

Herjavec and Plese separated on July 24, 2014 after 24 years of marriage with three adult children. Plese filed for divorce in March 2015, wrote Mesbur.

Herjavec made his fortune with his cybersecurity software business called Brak. Herjavec created a family trust in 1996 and the next year, transferred 75% of his Brak shares into his family trust.

Brak was sold to ATT for $31 million in 2000.

This windfall gave both Herjavec and his optometrist wife, “unimagined wealth, which would change their family’s life and lifestyle fundamentally,” wrote Mesbur.

In 2000, the couple bought their Bridle Path-area mansion — which featured an indoor swimming pool, a ballroom, many bedrooms, many bathrooms and an enormous garage — for $7 million (sold last year for $17.4 million) as well as a $2.6 million recreational property on Fisher Island, Fla. (now worth $4.8 million).

Luxurious boats and expensive cars, such as rare $1.5-million Ferrari, were purchased. Their children attended exclusive private schools as Plese stopped working outside the home.

His current wife was paid a salary equivalent to her Stars job by her spouse to sell two concepts to the BBC on behalf of her husband’s company.

The judge was satisfied that, although Johnson “isn’t an arms length party,” she performed “sufficient work” to justify her pay.