A sense of dutifulness pervades “Freeheld,” a glorified TV movie-of-the-week that doesn’t do full justice to either the real-life story on which it’s based or to its committed cast. It simply pushes all the right buttons without doing anything unexpected, but still manages to carry an emotional impact despite its predictability. In that respect it follows the pattern of “Philadelphia,” which was also written by Ron Nyswaner and now seems like a rather dated model.

Based on a similarly-titled 2007 documentary by Cynthia Wade, it’s the story of Detective Laurel Hester (Julianne Moore), a 23-year veteran of the police department in Ocean County, New Jersey, and for most of her life a closeted lesbian. She comes out—haltingly—when she falls in love with Stacie Andree (Ellen Page), a tomboy mechanic whom she meets at a volleyball game, and they move into a house together. Things soon change for the worse, however, when Laurel is diagnosed with advanced lung cancer.

Knowing that she has only a short time to live, Hester tries to make arrangements to have her pension benefits assigned to Andree, but the move faces resistance from the elected five-member Board of Freeholders, who direct the county government. Her cause is taken up by her long-time partner Dane Wells (Michael Shannon), who overcomes his initial anger that Laurel hadn’t told him of her sexual orientation long ago to become her most reliable ally on the force. But it also becomes a crusade for Steven Goldstein (Steve Carell), a flamboyant gay activist who happily brings members of his group Garden State Equity in to face the freeholders and turn Hester’s struggle into a media event. The resultant bad publicity—along with the shift of attitude among the public and, most significantly, her fellow officers—ultimately compels the Board to reconsider its decision, something that its most sensible member Bryan Kelder (Josh Charles) had thought the best course from the start. (The other four are depicted as varying degrees of Lionel Barrymore’s Mr. Potter.) There’s a predictably triumphant conclusion, tinged nevertheless by the inevitability of Laurel’s condition.

The major strength of “Freeheld” lies in its affecting personal relationships, not only that between Laurel and Stacie, which Moore and Page portray with sensitivity and grace, but that between Laurel and Dane, to whom Shannon brings an impressive measure of stalwart dignity and unwavering compassion. Once the film gets into the more public facets of the story, however, it becomes increasingly formulaic and obvious—a common failing in uplifting fact-based films that aim retrospectively to reassure viewers that they would certainly have taken the right, unbiased stance at the time. A culminating scene in which the police squad that’s heretofore refused to stand by Hester suddenly provides mass support at her final plea before the Board comes across as a manipulative contrivance, and only one among many. One might have expected director Peter Sollett, who exhibited such a subtle hand in “Raising Victor Vargas,” to have exercised some restraint at such moments, but he doesn’t.

That becomes most evident in the size of Carell’s performance. Goldstein might well have been a larger-than-life character, but except for a few moments in which he quiets down, Carell plays him like a stereotypical force of nature, turning him into someone perilously close to a sitcom caricature of the florid gay man. Perhaps he was simply making up for the preternatural stillness of his role as John du Pont in “Foxcatcher,” but it would have been better if Sollett had reined him in even a trifle. On the other hand, Shannon holds back when he might have gone for broke, and manages a refined version of a character that might also have gone into stereotypical mode.

As persuasive as he is, however, “Freeheld,” as one might expect, basically belongs to Moore. In the picture’s opening reels she creates a credible portrait of a tough, capable cop determined to overcome the barriers that her gender, let alone her sexual preference, pose to her ambition to win a promotion to lieutenant. She and Page also play the scenes of their meeting and the gradual realization of their relationship with genuine feeling and welcome reticence. But it’s with the diagnosis of cancer that her performance moves to another level, reaching a depth which goes beyond externals like the shaving of her head to a physical immersion in Laurel’s infirmity that’s positively grueling to watch. And she and Page, who endows Stacie with an agreeably boyish cast (despite an overdrawn scene in which she proves her mettle as a mechanic), manage the touching final scenes with real feeling without milking them for pathos. The supporting cast, unfortunately, do not match the sensitivity of Moore, Page and Shannon; some of the actors playing the freeholders and the other cops in Hester’s squad are overbearing and amateurish, though Dennis Boutsikaris, as the chair of the Board, manages a turn that’s nicely subdued by comparison to his colleagues. From a technical perspective the film is simply proficient, with Jane Musky’s production design emphasizing a lived-in look and Maryse Alberti complementing it with naturalistic cinematography while Hans Zimmer and Johnny Marr contribute a gentle, unobtrusive score.

At its basis “Freeheld” is an old-fashioned tearjerker with an inspirational message about the struggle for gay rights. It has a by-the-numbers feel, but the quality of the acting in the major roles lifts it above the norm.