Win McNamee / Invision/AP 1 / 25
Win McNamee / Invision/AP 1 / 25

She's now the ecstatic mother to her daughter, Blue Ivy Carter, nearly 13 months, but Beyonce dealt with the ultimate maternal anguish before that famous pregnancy: a miscarriage. Last year, the 31-year-old singer's husband, Jay-Z, briefly referenced the tragedy in "Glory," the rap track recorded within days of Blue's Jan. 7 birth, but Beyonce hasn't ever discussed the loss.

PHOTOS: Beyonce's pregnancy with Blue

In a surprising moment of candor, she opens up for the first time about the incident and its aftermath in "Life Is but a Dream," her new documentary debuting on HBO in February. "About two years ago, I was pregnant for the first time," the Grammy winner says in one scene. "And I heard the heartbeat, which was the most beautiful music I ever heard in my life."

She and Jay-Z (they wed in April 2008) were naturally overjoyed about their baby-to-be. "I picked out names," Beyonce recalls. "I envisioned what my child would look like ... I was feeling very maternal."

PHOTOS: Stars who have struggled to conceive

But something went wrong in the early stages, the "Love on Top" singer reveals. "I flew back to New York to get my check up -- and no heartbeat," she says. "Literally the week before I went to the doctor, everything was fine, but there was no heartbeat."

The superstar (who will perform at the Super Bowl halftime show this Sunday, Feb. 3) dealt with the heartache the best way she knew how: through music.

PHOTOS: Meet Blue Ivy Carter

"I went into the studio and wrote the saddest song I've ever written in my life," she says, although she doesn't name the track. "And it was actually the first song I wrote for my album. And it was the best form of therapy for me, because it was the saddest thing I've ever been through."

All of which made her successful pregnancy with Blue Ivy all the more exciting and joyful. "Being pregnant was very much like falling in love," she muses. "You are so open. You are so overjoyed. There's no words that can express having a baby growing inside of you, so of course you want to scream it out and tell everyone."

PHOTOS: Beyonce's best VMA moments

After months of understandable secrecy, she finally did tell everyone -- in one of the most tweeted moments in history -- by revealing her bump on the red carpet at the MTV Video Music Awards in Los Angeles on Aug. 28, 2011. Later in the evening, she rubbed her growing belly at the tail end of a lively rendition of "Love on Top."

This article originally appeared on Usmagazine.com: Beyonce Opens Up About Her Miscarriage: "The Saddest Thing I've Ever Been Through"

MORE ON WONDERWALL:

Video: Celebs without makeup

Beyonce and Jay-Z celebrate Blue Ivy's first birthday

GQ names Beyonce the Sexiest Woman of the 21st Century