NEW YORK — On ABC’s “How to Get Away With Murder,” Viola Davis plays the cunning, sexual and mysterious Annalise Keating, a dogged law professor with blood on her hands.

But in her upcoming movie “Custody,” which premiered Sunday at Tribeca Film Festival, people will see another side of the Emmy Award-winning actress, who picks up the gavel as a beleaguered New York judge in the throes of a messy custody case.

At the heart of the legal drama — which is still seeking a distributor — is Sara Diaz (Catalina Sandino Moreno), a working-class single mother whose two young kids are taken away when her son’s teacher calls child services, after noticing bruises on his arms and a cut above his eye. Hayden Panettiere plays Alexandra Fisher, a recent law-school graduate assigned to Sara’s case, while Davis is Martha Schulman, whose anxieties outside the courtroom include a cheating husband (Tony Shalhoub) and a son (Nicholas L. Ashe) just off to college.

Davis, a producer on the film with husband Julius Tennon, was sent the script two years ago by writer-director James Lapine (“Into the Woods”) and was instantly compelled.

“I know the social services system and felt like it was an honest depiction of what people go through when they’re caught in the midst of it,” says Davis, 50. “I loved the blurred lines between what we deem a ‘bad parent’ who’s caught in the system and a parent who’s just doing the best they can.”

Moreno is best known for her Oscar-nominated turn in 2004 Colombian thriller “Maria Full of Grace.” Meeting with Lapine, she conveyed her own fierce protectiveness as a mother.

“I have a 7-year-old and that’s one of the things that James asked: ‘What would you do?’ ” says Moreno, 34. “I was like, ‘I would do as much as I could.’ As a mother, you’re a tiger when something happens to your child. I expressed my anxiety at how crazy I’d be if anything like that happened to me, and I think he got how passionate I was.”

As the court — and audience — learn more about Sara, it’s up to the individual to decide whether she’s fit to be a mother, or if in reprimanding her son, she crossed the line into abuse.

“What mistakes are just regular human mistakes and what mistakes are worthy of your child being taken away from you?” Davis says. “It’s like that minefield of constant juggling of perception and critiquing and fighting for the child, and being compassionate toward the mother.”

Lapine also raises the issue of class. Sara is forced to take time off from her minimum-wage factory job to go to court and use a court-assigned attorney because she can’t afford one herself. It’s a struggle that Davis could sympathize with, having grown up in abject poverty in Central Falls, R.I., and known family members whose children were taken away.

For impoverished women, it’s a struggle “finding the means to get your child back and making enough money so you can have a [home] the child can come back to,” Davis says. On the flip side, “you see the system doing the best they can with two social workers for every 500 cases. It’s a really complicated system, and [this movie is] an unbiased assessment of the system.”