Keith King may have lost a wife, but he gained nearly $9million from his romantic rival, all thanks to a quirk of North Carolina's legal system.

Superior Court Judge Orlando Hudson, of The Staircase documentary fame, awarded Keith King $8.8million in compensatory and punitive damages on Thursday from his wife Danielle's Texan lover, Francisco Huizar III.

King had sued Huizar for, among other complaints, criminal conversation and alienation of affection, accusing him of breaking up his marriage.

Love triangle on trial: Keith King (left) was awarded Thursday $8.8million in damages from his estranged wife's lover, Francisco Huizar III (right)

King had sued his rival for seducing his wife, Danielle King (pictured), and breaking up their marriage

North Carolina is one of a few states where jilted spouses can sue affair partners, reported Durham Herald-Sun.

Huizar, who lives in San Antonio and earns $84,000 as a marketing tour manager, plans to appeal the verdict.

Attorney Joanne Foil said the extramarital affair and an alleged assault by Huizar cost King's company, BMX Stunt Shows, revenue and an employee, since Danielle King worked for the company.

Huizar's attorney, Cheri Patrick, argued that the Kings' six-year marriage was crumbling before Huizar ever met Mrs King at a BMX show.

Patrick described King, who is 15 years older than his 33-year-old wife, as controlling and manipulative. The couple have a five-year-old daughter together.

The lawyer for the defendant recounted in court how King routinely reviewed the contents of his wife's phone, tracked her movements, forced her to wear bikinis and stilettos and did not allow to dye her blond locks a different hue, among other things.

When called to testify, Danielle King claimed that she was the one who romantically pursued Huizar and said her marriage to Keith was an unhappy one from the outset.

Paramours: Mrs King (left) told the court she was the one who pursued Huizar (right) romantically and argued that her marriage was beyond repair

Danielle and Huizar crossed paths for the first time in August 2015 at a BMX show in New York and struck up an affair, which continued through the summer and into the fall and winter.

According to courtroom testimony, Huizar and Danielle met up for trysts in Durham, North Carolina, and regularly talked on the phone. In February 2016, the married woman's lover even joined her on a spa vacation paid for by her husband.

Foil argued that Huizar’s 'relentless behavior' made it all but impossible for the Kings to save their troubled marriage.

Keith and Danielle tied the knot in 2010 and have a five-year-old daughter together (pictured with mom)

Familiar face: North Carolina Superior Court Judge Orlando Hudson, of The Staircase documentary fame (pictured), on Thursday found in favor of Keith King

After several attempts to patch things up, the couple separated in January 2017, according to Keith’s lawyer, although both Danielle and Huizar’s attorney pointed to documents indicating that the couple had split up months earlier, in August 2016.

In early January, Danielle moved out of her husband's house and rented an apartment, with Huizar on the lease. When her estranged husband came by one day and found her lover there, the men came to blows and Huizar put him in a choke-hold, according to court papers.

His lawyer argued that Huizar was only trying to protect his terrified girlfriend from her husband.

When Judge Hudson delivered the verdict at the conclusion of the civil trial on Thursday, he remarked that it was a 'textbook case' of how not to end a marriage in North Carolina.

Hudson is well-familiar to Netflix viewers, having presided for many years over the high-profile murder case of Durham-based author Michael Peterson, which is the subject of the popular true-crime documentary The Staircase.