Television writer Bill Oakley told The Ringer that The Simpsons‘s first gay episode, “Homer’s Phobia,” almost didn’t air because of the network censors.

The episode included an appearance by Hairspray director John Waters as an antiques store owner named “John” who befriends the family and introduces them to gay culture. Homer wonders if his son Bart might be gay and tries to make him straight. His attempts fail, and Homer and his friends, in desperation, take Bart to go shoot captive reindeer. When Bart refuses to shoot, the reindeer become hostile, and John saves the day.

At the end of the episode, Homer sticks up for John when his friends call him “a sissy.” John quips: “Well, Homer, I won your respect, and all I had to do was save your life. Now, if every gay man could just do the same, you’d be set.”

The episode ended up winning an Emmy, but it was a struggle for the show to even get it on TV.

“Homer’s Phobia” aired on February 16, 1997, several months before Ellen came out on her sitcom. Networks at the time shied away from gay content, scheduling episodes that depicted gay people at later times if gay content was aired at all.

Oakley co-wrote the episode and submitted it to the Fox censor for approval. Usually scripts would receive small comments about individual words, but this episode got dozens of notes about “every single thing in the episode that had to do with being gay or the word ‘gay.'”

The show chose to produce the show anyway, risking a year of work on an episode that might never have aired. “Over the next 10 months, we just kept our fingers crossed,” Oakley said.

Later, the episode was re-submitted and only received a comment stating it was “acceptable for broadcast.” Oakley thinks that a new censor came in when Fox got a new president in late 1996.

The episode won an Emmy for Outstanding Animated Program and a GLAAD Media Award. It included the famous “gay steel mill” scene below.