“Clear eyes, full hearts, can’t lose” was the onscreen mantra of “Friday Night Lights” dating back to its first season, but it’s one that was constantly tested offscreen.

From its ceaselessly uncertain future as an NBC drama to its virtual abandonment by TV Academy voters (one Emmy victory in its first four years, for casting), there was always someone trying to pin a loss on “Lights.”

Sunday at the Primetime Emmys, however, “Lights” did its touchdown dance.

Capping a run that was extended three seasons only by a virtually unprecedented production deal between NBC and satcaster DirecTV, “Lights” won two high-profile drama kudos on Sunday, one for lead actor Kyle Chandler as Coach Eric Taylor, the other for exec producer Jason Katims’ script for the series finale.

“Sometimes it takes a while for your moment to come around,” said David Nevins, who was president of “Lights” producing shingle Imagine Television before becoming Showtime’s entertainment topper last year. “But I couldn’t be happier. Jason and Kyle are two of the most talented and most menschy people I’ve ever worked with.”

Though continually praised by critics for its nuanced, powerful writing and acting, “Lights” operated so far under the radar that it did not receive a nom in either of those categories until 2010, after the series’ second season of firstrun episodes on DirecTV. That year, Chandler and co-star Connie Britton each were tapped, as was writer Rolin Jones for an episode that dealt with a character (Zach Gilford’s Matt Saracen) coming to grips with the death of his father.

Delicate handling of such serious material, without becoming maudlin, was the series’ hallmark, but it was widely perceived that for a series relegated to the outskirts of the TV world, “it’s an honor to be nominated” was the new mantra.

But, quietly, the groundswell of support for “Lights” grew. This year not only were Chandler and Britton nominated again, alongside Katims for writing, but the show received its first drama series nom.

Though it lost to four-peater “Mad Men” for the drama grand prize, “Lights” had to knock off some serious competition to win its two Emmys. Chandler outpolled Steve Buscemi (“Boardwalk Empire”), Michael C. Hall (“Dexter”), Jon Hamm (“Mad Men”), Hugh Laurie (“House”) and Timothy Olyphant (“Justified”), while in the drama writing category the show’s rivals included “Game of Thrones,” the pilot of “The Killing” and two episodes of “Mad Men,” including the ballyhooed “The Suitcase,” written by showrunner Matthew Weiner.

Taking the Emmy stage to accept his writing award, the unexpected triumph wasn’t lost on Katims.

“To the Academy, I will cherish this,” he said, before uttering one more time, “Clear eyes, full hearts, can’t lose.”