(Photo by Chavie Weisberger/Facebook)

A mother who lost her children after coming out as a lesbian has been granted full custody after a lengthy legal battle.

Chavie Weisberger was formerly part of a strict Hasidic community.

After she came out and divorced her husband in 2009 she lost custody of her three children.

Related: 7-year-old put into father’s custody after mother ‘raised him as female’

Weisberger from Brooklyn, New York, was at first given partial custody.

However, she lost any custody of her children after her ex-partner, Naftali Weisberger sued her.

Related: Lesbian mother granted ‘husband’s rights’ in landmark case

The judge ruled that her sexuality meant that she was not complying with a formerly agreed religious upbringing clause.

The two became embroiled in a lengthy legal battle as Naftali accused Chavie of “radically” changing her lifestyle.

The judge said the couple’s divorce agreement made it so he had to “consider the children’s religious upbringing as a paramount factor in any custody agreement”.

Related: Lesbian couple’s baby murdered by birth father

The ruling meant that Chavie was only allowed to have supervised visits with her children and she had to keep her sexuality hidden from the two youngest children.

Chavie appealed the ruling last month and the appeals court said the judges original ruling lacked “sound substantial basis”.

She has now been granted full custody but must still practice full religious observance.

Michael Stutma, a top divorce lawyer, said that the complex case “really shines a light on the tensions that exist between the secular world an insular religious community”.