This Father’s Day, let’s take a moment to appreciate Mitch and Cam, the gay dads of the sitcom Modern Family, played by Jesse Tyler Ferguson and Eric Stonestreet.

Despite being together the better part of a decade, raising a daughter, standing by each other, and generally being as wholesome as possible, they were forced to live in sin for the first half of the show’s run, thanks at least in part to Arnold Schwarzenegger.

Getting these TV dads to the altar, along with thousands of other real-life couples in California, took years of work, both onscreen and off, as well as overcoming loud opposition from conservatives … which is ironic, considering that Mitch and Cam were among the most traditional couples on television.

Modern Family has its in a dark time for the American sitcom. In 2007, the format was about 60 years old, and many critics thought it was coming to an end. Ratings for TV comedies were down across major networks, and it seemed every new show was just a tiresome retrod of something that had come before. When even Norman Lear declares the sitcom is dead, it’s hard to feel much optimism.

But as luck would have it, Modern Family came along at just the right time to prove those doom-and-gloom predictions wrong. The genre wasn’t dead. It just needed a shakeup. Created by veterans of shows like The Golden Girls and Frasier, Modern Family took nontraditional family structures that had occasionally appeared on sitcoms (divorced couples, young parents, same-sex households), mashed them up into a giant ensemble, and provided a fresh coat of paint by skipping the tired old multicam format and opting instead for the mockumentary style popularized by The Office

But the gay dads almost didn’t make it to air. While the show was in development, the creators worried viewers would be turned off by the idea of a same-sex couple with a baby. A gay colleague even encouraged them to turn Mitch and Cam into minor background characters to avoid scaring away viewers. It wasn’t an unreasonable concern at the time: Though gay characters had grown more prominent on television in the early 2000s, couples were less common and tended to only appear on cable shows. What’s more, at the time Modern Family was being developed, California voters approved Proposition 8, a ballot measure banning marriage equality. It was clear that many Americans were still deeply uncomfortable with the idea of treating gay couples as equals. 

But then again, if they were going to make a show called Modern Family, it would be a little hypocritical to remove a type of family that had only recently started appearing on contemporary shows. In the end, the showrunners decided to keep Mitch and Cam, and resigned themselves to losing audience members. 

When the show premiered in September of 2009, with Ferguson as Mitch and Stonestreet as Cam, it was an immediate hit, to everyone’s relief. Not only that, but viewers were particularly taken by the gay couple. That was thanks to a clever strategy: In order to ease conservative viewers into watching, the writers deliberately focused early storylines on Mitch and Cam’s parenting, rather than on any gay issues. Plots tended to be about taking their daughter to daycare and a pediatrician, or buying diapers—things that would be relatable to gay or straight audiences. With Mitch as a successful attorney and Cam as a teacher who gave up his job to be a stay-at-home parent, they actually have the most conservative family dynamic on the show, as long as you can overlook gender, which viewers were largely willing to do. Aside from some complaints from far-right extremists, who called the show “poison” for featuring a same-sex couple, ratings were high.

Still, Mitch and Cam were sometimes treated differently from other couples on the show. For one thing, they were far less likely to demonstrate physical affection, and they couldn’t be married because it wasn’t yet legal.

The issue of physical affection became a particular sticking point among gay viewers. Mitch and Cam didn’t so much as kiss during the show’s entire first season, highlighting the difference in how they were portrayed compared to the show’s straight couples.

But that changed in season two with an episode titled “The Kiss.” Cam confronts Mitch about their lack of physical contact, and after a heart-to-heart, Mitch comes to understand just how much that stuff matters; in the episodes that follow, viewers saw signs of physical affection gradually increase between the two.

That still left one area of inequality: Marriage. Proposition 8 remained the law in California, where the show was set, and through a strange series of political moves, the ban on gay marriage was defended by then-Governor Arnold Schwarzenegger. Schwarzenegger’s track record on queer equality was poor: He vetoed bills recognizing the contributions of Harvey Milk and blocked efforts to legalize marriage equality. But in June of 2013, the governor proved no match for the U.S. Supreme Court, which overturned Proposition 8. Just like that, marriage was legal in California for same-sex couples—including fictional ones.

Modern Family was heading into a summer break when the ruling came down, but the writers leapt into action to plan a wedding for Mitch and Cam. It began with the proposal at the start of season five, and continued with a year-long arc that ended with a wedding in June of 2014. Modern Family was cautious to write Mitch and Cam’s journey to the altar in a way that wouldn’t immediately alienate conservative viewers, with episodes focusing on general wedding-planning hijinks rather than specifically queer issues.

That episode coincided with thousands of real-life marriages, including one for Modern Family’s own Jesse Tyler Ferguson. Behind the scenes, Ferguson and his then-boyfriend Justin Mikita were vocal advocates for the freedom to marry, and tied the knot just before Ferguson’s television wedding. “I have two husbands, you guys,” Ferguson joked at an awards show. “Remember when we could have zero? Well, now I have two.”

Mitch and Cam’s union also converged with surging public support for the freedom to marry, with polls showing for the first time that a majority of Americans supported marriage equality. There are a lot of reasons public opinion changed, but research from MIT demonstrated that fictional characters like Cam and Mitch likely played a meaningful role in showing Americans that same-sex couples are nothing to be scared of.

Not a bad legacy for two gay dads who nearly never made it to air.