Actress Lena Dunham has revealed that she underwent a total hysterectomy after years of suffering pain caused by endometriosis.

The 31-year-old actress and writer told why she decided to have the procedure – the surgical removal of the cervix and uterus – in an essay for Vogue.

The creator and star of hit TV series Girls said the decision followed “years of complex surgeries measuring in the double digits”.

In the essay, excerpts of which were republished by the Endometriosis Foundation of America, Dunham said she was looking at her options when it comes to motherhood.

“I may have felt choiceless before, but I know I have choices now,” she wrote.

“Soon I’ll start exploring whether my ovaries, which remain someplace inside me in that vast cavern of organs and scar tissue, have eggs. Adoption is a thrilling truth I’ll pursue with all my might.”

During the procedure, the US star discovered other complications.

“In addition to endometrial disease, an odd hump-like protrusion and a septum running down the middle, I have retrograde bleeding, a.k.a. my period running in reverse so that my stomach is full of blood,” she wrote.

“My ovary has settled in on the muscles around the sacral nerves in my back that allow us to walk.

“Let’s please not even talk about my uterine lining. The only beautiful detail is that the organ – which is meant to be shaped like a light bulb – was shaped like a heart, ” she added.

Endometriosis is a painful condition that occurs when tissue that lines the uterus is found outside it.