Oprah Winfrey and Laura Dern appear with host Ellen DeGeneres at a taping of “The Ellen DeGeneres Show.” (Michael Rozman/Warner Bros./AP)

For a year before the television episode that buoyed, then tanked, and ultimately defined Ellen DeGeneres’s career debuted, rumors swirled about the comedian’s sexuality.

She was gay, the gossips whispered, and soon the character she played on her TV sitcom, “Ellen,” might come out as a lesbian.

The build-up gave DeGeneres, once Showtime’s “Funniest Person in America” a chance to play it coy.

Maybe, she teased, her bookstore-managing TV character Ellen Morgan wasn’t coming out as a lesbian, but Lebanese.

Then on the cover of Time magazine’s April 14, 1997, issue, DeGeneres unabashedly declared: “Yep, I’m Gay.”

And two weeks later, before a live studio audience on April 30, 2017, Ellen Morgan the character said that she was gay, too.

“It became more important to me than my career,” DeGeneres recently told the Associated Press during an interview reflecting on the episode’s 20th anniversary. “I suddenly said, ‘Why am I being, you know, ashamed of who I am just to be successful and famous in society’s eyes?’”

It was a public coming out that earned DeGeneres bomb threats, thank-you cards and the title of first openly gay leading character on television.

On Friday, two guest stars from that historic episode — Oprah Winfrey and actress Laura Dern — will join DeGeneres on her talk show to discuss its 20th anniversary and the progress of LGBT issues.

In a preview clip of the conversation, DeGeneres says in her monologue that her 1997 declaration was “before ‘Will & Grace,’ Cam and Mitchell, and Hoda and Kathie Lee.”

Congress had passed the Defense of Marriage Act (which defined marriage for federal purposes as between a man and a woman) just six months before and the LGBT community, eager for a hero, found one in both Ellens. “It took ovaries,” wrote playwright and LGBT advocate Claudia Allen in a column at the time praising DeGeneres.

But with the admiration came trouble, first from the Christian right (“Ellen DeGenerate” said the late Rev. Jerry Falwell) and then from her bosses at Disney-owned ABC, who canceled “Ellen” a year later.

Even before the coming-out episode, the sitcom was struggling. It had dropped from fifth to 36th in ratings. Ellen Morgan had no love life. DeGeneres thought a sexual revelation could be a natural turning point for the show and critics predicted that if the comedian and her character were finally free to be sexually honest, “Ellen” could be saved.

Writing the actual episode, though, was so top secret that the script was printed on dark red paper to make photo copying impossible. The drafts were locked in safes, DeGeneres told the Associated Press, and shredded at the end of each day.

“It was crazy,” she said. “It was like we were spies or something.”

They named it “The Puppy Episode,” not because it featured dogs, but because executives initially rejected the plot twist and said, according to DeGeneres: “Well get her a puppy. She’s not coming out.”

The episode opens with Ellen Morgan in the bathroom, taking too long to prep for a date with a male TV reporter on assignment in Los Angeles. From the family room, her friends tell her to “quit jerking us around and come out already!”

At dinner, the reporter’s producer, Susan, played by Dern, joins them for dessert.

The women find instant chemistry, and Susan later tells Ellen that she is attracted to women.

But the next day, Ellen lies to her friends, claiming she and the reporter had amazing sex. She later admits the truth to her therapist, played by Oprah.

“Has there ever been anyone you felt like you clicked with?” the therapist asks.

Ellen shakes her head.

“And what was his name?”

Ellen pauses: “Susan.”

At the end of the episode, Richard and Susan prepare to depart for home at the airport. Ellen arrives with an admission for Susan, at first struggling to articulate it.

“This is so hard, but I think I’ve realized that I am …” Ellen says, pacing around the terminal in a tender, raw moment. “I can’t even say the word. Why can’t I say the word … why do I have to be so ashamed … I’m so afraid to tell people.”

The camera turns to face the two women, who are standing beside the flight attendant’s podium that is inconveniently equipped with a microphone.

“Susan,” Ellen says, learning toward Dern and over the microphone. “I’m gay.”

The live studio audience laughed and cheered.

Before that moment, DeGeneres had not said aloud that last line.

“I realized how charged that sentence was because, you know, when you’re gay, the only time you say ‘I’m gay’ is when you’re revealing it to someone, when you’re telling your parents or when you’re telling someone close to you. Because most people never have to say, ‘I’m straight,'” DeGeneres told the Associated Press, explaining that the scene always made her tear up. “So Laura (guest star Laura Dern) kept saying, ‘Just don’t say it,’ because she saw how hard it was for me.”

Though the episode would eventually win a Peabody and an Emmy, it ultimately killed the sitcom — and, temporarily, DeGeneres’s career.

Advertisers fled. Season five revolved almost entirely around Ellen’s homosexuality and ratings tanked. Before an episode where Ellen Morgan kisses another woman, the network required a “parental advisory,” over DeGeneres’s objections.

At the end of the season, ABC canceled Ellen.

Then-ABC President Robert Iger told Diane Sawyer the decision had nothing to do with DeGeneres’s sexual orientation, but that viewers were turned off when the show “became a program about a lead character who was gay every single week.”

DeGeneres said she had no regrets.

“If I just had this one year of doing what I did on TV, I’d take that over 10 years of being on a sitcom and just being funny,” she told Sawyer.

But for three years after that, DeGeneres fell into a deep depression. She couldn’t get work and suddenly was viewed as not a comedian, but a gay comedian.

In 2000, she returned to her stand-up comedy roots, prepared for another variety show on CBS and wrote an HBO special titled “Ellen DeGeneres: The Beginning” that left out any overtly gay or political humor.

“I knew I didn’t want to do that,” DeGeneres told the Los Angeles Daily News in 2000. “It’s not who I was.”

After “Ellen” failed, she realized that making her comedy all about her sexuality was a miscalculation. “I am the same person and I have the same sense of humor and the same thoughts, and I’m not going to turn my show into a gay show just because everybody knows I’m gay now,” DeGeneres said.

In 2003, she wrote another HBO special and introduced herself to a new generation of potential fans as the voice of a forgetful blue tang fish named Dory in the Pixar movie “Finding Nemo.” That same year, her current talk show, “The Ellen DeGeneres Show,” debuted on NBC. It has won dozens of Emmys and made DeGeneres everybody’s BFF.

Last year, President Barack Obama awarded DeGeneres the Presidential Medal of Freedom, the highest honor for a civilian in the United States.

Comedian and actress Ellen DeGeneres grew teary as she accepted the Presidential Medal of Freedom from President Obama. (WhiteHouse.gov)

“For me to crawl out of that and to accomplish what I’ve accomplished with the show and with my brand and with my production company, and to succeed after all that,” DeGeneres recently told the Associated Press. “[It] makes me realize that no matter how dark something gets, and no matter how bad something gets, that there’s always a possibility of good coming from it.”

Others in the LGBT community have credited DeGeneres for making them feel comfortable with themselves and their sexuality, including Eric Marcus, creator and host of the podcast “Making Gay History.”

“For everyday people,” Marcus told the AP, “Ellen made gay okay.”

More for Morning Mix

‘The Simpsons’ has a grim take on Trump’s first 100 days

‘Bachelor’ Chris Soules arrested after deadly crash that killed Iowa farmer

With self-deprecation on menu for presidents at correspondents’ dinner, it’s no wonder Trump is skipping it