A Long Island couple and a neighbor with whom they had a threesome have been granted “tri-custody” of their 10-year-old son in a groundbreaking ruling.

“No one told these three people to create this unique relationship,” Suffolk County Supreme Court Judge H. Patrick Leis III wrote in the ruling for the first-of-its-kind case in New York.

Bay Shore residents Dawn and Michael Marano, who wed in 1994, had a conventional marriage until they befriended downstairs neighbor Audria Garcia in 2001.

Garcia had been living with her boyfriend, but when they split up, she moved upstairs and “began to engage in intimate relations” with the Maranos, Leis’ ruling says.

Because Dawn Marano, 47, was infertile, Michael Marano, 50, fathered the boy, born on Jan. 25, 2007, with Garcia, 48, court papers say.

“It was agreed, before a child was conceived, that [the Maranos and Garcia] would all raise the child together as parents,” the judge said.

Dawn Marano’s insurance covered Garcia’s pregnancy, and the two women attended doctor appointments together, the papers say. They also took turns getting up in the night to feed the baby.

The threesome was one big happy family for 18 months until Garcia and Dawn Marano decided to become a twosome. They moved out and into a new home in nearby Central Islip in 2008.

Then Michael Marano sued Garcia for custody of their son. Dawn Marano then sued her husband for divorce.

Michael Marano and Garcia agreed to joint custody, but Dawn felt left out. As neither a biological nor adoptive mom to the boy, she had no automatic legal right to custody.

Although she still lives with Garcia, Dawn Marano filed another suit “to secure custody rights for [the boy] because she fears that without court-ordered visitation and shared custody, her ability to remain in [the boy’s] life would be solely dependent upon obtaining the consent of either Audria or [Michael],” Judge Leis explained.

Michael Marano opposed his ex-wife’s custody bid and the case went to trial.

Leis chastised him in the ruling Wednesday, noting that no one had told the dad “to conceive a child with his wife’s best friend.”

In awarding Dawn Marano shared custody, Leis cited a ruling by the state’s highest court last summer that allowed nonbiological or adoptive parents to seek custody of a child if they had a prior relationship with that child.

The judge took cues from the boy himself in making the unusual decision.

Asked how he told his two moms apart, the child had explained that one was the “mommy with the orange truck” and the other the “mommy with the gray truck.”

Leis concluded the boy knows the “two women as his mother.”

He also credited all three parents with raising their son “in a loving environment.”

Leis granted Dawn Marano Wednesday nights with the boy, as well as one week of vacation during the school year and two weeks in the summer.

Garcia has residential custody, while Michael Marano gets the boy on the weekends.

“They’re thrilled with the ruling, absolutely thrilled,” said Dawn Marano’s attorney, Karen Silverman.

Michael Marano, however, was upset by the decision.

“I am going to appeal,” he told The Post.

Silverman said ruling is the first time a judge in the state has granted tri-custody to three parents for one child.

New Jersey saw a similar case in 2015, with the parents including a gay male couple and a straight woman.

Manhattan family-law expert Nancy Chemtob, who is not involved in the case, said Leis did the right thing by “protecting the child’s best interest.”

Additional reporting by Lorena Mongelli and Alex Taylor