Emilia Clarke is at the top of her career and living out all her wildest childhood dreams.

"Game of Thrones" – where she plays Daenerys Targaryen, the Mother of Dragons – is about to enter its eighth and final season, and she's become one of the most recognizable faces on television.

But Clarke's life isn't a complete fairy tale. In an essay just published by The New Yorker, titled "A Battle for My Life," she reveals she almost died while filming the HBO series.

In February 2011, just as "Thrones" was premiering and on its way to becoming a worldwide phenomenon, Clarke underwent her first of two brain surgeries and an extensive and grueling recovery period.

While working out with her trainer in London, she suffered from a ruptured brain aneurysm. At 24 years old, she says she "started to feel a bad headache coming on" but pushed through only to collapse in the bathroom. After being rushed to the hospital and having an MRI, the results were dire.

'GAME OF THRONES' STAR KIT HARINGTON SAYS HE STARTED THERAPY AFTER FILMING THIS 'TERRIFYING' SCENE

"The diagnosis was quick and ominous: a subarachnoid hemorrhage (SAH), a life-threatening type of stroke, caused by bleeding into the space surrounding the brain," she details in the article . "I’d had an aneurysm, an arterial rupture. As I later learned, about a third of SAH patients die immediately or soon thereafter. For the patients who do survive, urgent treatment is required to seal off the aneurysm, as there is a very high risk of a second, often fatal bleed. If I was to live and avoid terrible deficits, I would have to have urgent surgery. And, even then, there were no guarantees."

She made it through the surgery but after two weeks of recovery, the nurse asked Clarke what her name was to which she responded with "nonsense words" and panicked because "I am an actor; I need to remember my lines. Now I couldn’t recall my name."

She was suffering from a condition called aphasia which luckily passed after about a week.

'GAME OF THRONES' SEASON 8 EPISODE RUN TIMES OFFICIALLY REVEALED BY HBO WITH MOST CLOCKING IN OVER 60 MINUTES

Clarke returned to the "Game of Thrones" set, press interviews and traveling after about a month, but during that time she learned, she had another "smaller aneurysm" on the other side of her brain that could “pop” at any time.

She was still in pain and keeping it at bay with morphine while also suffering from extreme anxiety about dying in a random hotel while working.

In 2013, Clarke said she went for a brain scan – which is something she "now had to do regularly" – and discovered "the growth on the other side of my brain had doubled in size, and the doctor said we should 'take care of it.'"

She had the surgery at a New York City hospital but there was a complication and when Clarke woke she was "screaming in pain."

'GAME OF THRONES' STAR EMILIA CLARKE POSTS EMOTIONAL FAREWELL TRIBUTE TO HBO SHOW ON INSTAGRAM

"The procedure had failed. I had a massive bleed and the doctors made it plain that my chances of surviving were precarious if they didn’t operate again. This time they needed to access my brain in the old-fashioned way — through my skull. And the operation had to happen immediately," she explains.

"The recovery was even more painful than it had been after the first surgery. I looked as though I had been through a war more gruesome than any that Daenerys experienced. I emerged from the operation with a drain coming out of my head. Bits of my skull had been replaced by titanium," she adds.

EMILIA CLARKE ON NUDE 'GAME OF THRONES' SCENE: I DIDN'T USE A BODY DOUBLE

She spent a month at the hospital and was slipping into a dark mental place but she writes, "I survived" and "in the years since my second surgery I have healed beyond my most unreasonable hopes. I am now at a hundred percent."

Clarke, now 32, has decided to get involved with charities in the U.K. and the U.S. called SameYou, which "aims to provide treatment for people recovering from brain injuries and stroke."

And, of course, she said she feels "endless gratitude — to my mum and brother, to my doctors and nurses, to my friends" and calls herself "beyond lucky."