Nearly two decades ago, Maggie Gyllenhaal came crawling on her hands and knees into James Spader’s office, a memo clutched between her teeth – but it may as well have been a calling card. Gyllenhaal’s performance as Lee, the gagged and manacled office assistant/S&M sex slave in the now-notorious Secretary, set the tone for a career that has rarely lacked for daring.

In the years since, she has racked up a number of complex, even contradictory, roles: the defiant, self-absorbed ex-con in the indie film Sherrybaby; the capable, conflicted businesswoman drawn into the grubby world of arms dealing in the BBC thriller The Honourable Woman; and Eileen, the sex worker turned pioneering pornography director in David Simon’s dawn-of-porn series, The Deuce. She says she has long rejected cinema’s “fantasy version of the powerful woman” in favour of an “actual woman”, with “some aspects that are powerful, and some that are confused, broken and vulnerable. I want all of it!” she says, grinning from the vaguely Scandi-style sofa in her hotel suite.

She is in town to promote what may just be her messiest portrayal of an actual woman yet. In The Kindergarten Teacher, Gyllenhaal stars as Lisa, an outwardly sunny New York teacher with two children. But look a little more closely and things are darker. Her marriage, though loving, is entirely without spark, and her children seem distant, walled off behind smartphone screens. Lisa dreams of creating art of some kind, but at her weekly poetry class her work is dismissed as blandly derivative.

The Kindergarten Teacher.

Then one day after class, Lisa witnesses one of her pupils, five-year-old Jimmy, reciting a beautiful, opaque poem in a trance-like state. After learning that the poem is Jimmy’s own work, and realising that his family has little interest in nurturing his talent, Lisa appoints herself patron to this prodigy. She reads out his work at her poetry group, takes him to museum visits (without his family’s permission) to stir his creativity, and – here’s the first real red flag – gives him her phone number so that he can call her when he conjures up a masterpiece. Then she goes further still, and the film lurches into truly uncomfortable territory. Without giving anything away, “she does some incredibly problematic things”, Gyllenhaal says.

Adapted from an Israeli film of the same name, The Kindergarten Teacher is a psychological thriller disguised as a small-stakes indie drama, the tension ratcheting up horribly with each morally murky decision Lisa makes. During its festival run, Gyllenhaal would pop into screenings to hear the agonised reactions of audience members. “People would gasp, laugh, moan and make these noises,” she says gleefully. “But I think that’s what’s so beautiful about the way it’s constructed. You’ll go: ‘Wait, maybe I am still with her.’ Then: ‘No, no, I couldn’t possibly be.’ It’s so different for everybody, the point where they decide: ‘No, I absolutely can’t handle it any more.’”

That there is even a sliver of doubt in the audiences’ minds over whether to root for Lisa is testament to Gyllenhaal’s ability to bring her to life. This, after all, is the actor who managed to make a sadomasochistic submissive seem not just relatable to those of a more vanilla persuasion, but even ever-so-slightly wholesome. Her characters are suffused with a messy humanity that makes their every choice – as desperate, foolish or horrible as they may be – if not sympathetic, then at least in keeping with the cracked, flawed environment around them.

In the case of Lisa, it’s an environment where women are positioned as the facilitators of male creativity rather than being allowed to be creative themselves. “She is a woman who is starving, a woman with a vibrant, curious, artistic mind which has not been fed,” she says. “I think many women right now in America – and I imagine it’s the same in the UK – are waking up to that feeling. And, in some ways, I think it’s a cautionary tale. There are consequences for starving a woman’s mind, and the consequences here are … extreme.”

With Parker Sevak in The Kindergarten Teacher. Photograph: Allstar

Gyllenhaal, it seems, gives a great deal of thought to what drives the people she is playing. Then again, she seems to give a great deal of thought to just about everything. Her answers tend to be long and digressive, peppered with “hmm” and “interesting”. Unlike Lisa, it is safe to assume, she’s not artistically starved. At 41, she has reached that point of her career where – as in the case with The Kindergarten Teacher and The Deuce – she is producing projects as well as starring in them, and has optioned an Elena Ferrante novel that she plans to direct.

She has agency and autonomy now, although that hasn’t always been the case. There was the time early on in her career when, while auditioning for a “really bad movie with vampires”, she was told that she wasn’t “hot enough” and was encouraged by her manager to “sex it up a bit” for the second audition. (She wore leather trousers and a leopard print top, and still didn’t get the part.)

Even after Secretary, she was being told by people in the industry that, while they were desperate to cast her, she didn’t “mean enough money-wise”, a statement that you can’t really imagine being directed at a male actor who had just been the recipient of gushing reviews and a Golden Globe nomination. (No one balked at, say, Gyllenhaal’s brother, Jake, starring in a blockbuster such as The Day After Tomorrow off the back of Donnie Darko and a couple of other indies.) More recently still, she was told that, at 37, she was too old to play the romantic interest for a male character who was 55.

So you can understand when she says that, despite their obvious differences, Lisa stirred up in her “a personal feeling of the ways in which I’ve twisted myself – bent myself backwards – in order to do things that I thought I had to do in order to survive in this culture. And the ways in which that hurts, and the cost … the toll that takes on you.”

In season two of The Deuce. Photograph: Paul Schiraldi/HBO

Still, for all her empathy for the character, “it was not a pleasure to play Lisa because it’s hard to have to twist my mind around her very flawed logic”. In fact, so dark is the path that Lisa heads down that, at one point, Gyllenhaal doubted the film could be made. She was concerned that Parker Sevak, the child actor playing Jimmy, would struggle with the subject matter. “I thought: ‘Actually, I don’t know how we can do it and not for one minute make a five-year-old child feel that their boundaries have been crossed.’”

Gyllenhaal only changed her mind after considering that she, the film’s director Sara Colangelo and three of the film’s other producers were all mothers to young children and so were probably better placed than most to guide him through the process. (Gyllenhaal, who is married to the actor Peter Sarsgaard, has two daughters, aged 12 and six).

“Basically, I’ve worked a lot with kids, and I don’t think five-year-olds are actors,” she explains. “You can’t say to a five-year-old: ‘I need you to go deeper into this emotional space.’ No! But you can say: ‘When I clap my hands, you’re going to turn your head quickly, and you’re going to say: “I don’t want to go.”’ Or we would just have the camera across the room on a long lens, and he wouldn’t know it. Catching his childishness.

“We were trying to protect him from feeling uncomfortable. It’s interesting because his character, like any five-year-old, feels that the boundaries are in the wrong place. Children think: ‘Oh, wait – why am I being taken out of nap time?’ His character feels pretty much immediately that something is off, even if he doesn’t know how to say it.”

There is another complicating factor to the already fraught relationship between Lisa and Jimmy: the fact he is the child of Indian immigrants, and she is a white woman. Among otherwise positive reviews, this aspect of the relationship has prompted a few stirrings of disapproval. In an article for The Week, headlined “The Kindergarten Teacher has a race problem”, the critic Candice Frederick lamented the fact that the exploitation of a child of colour “goes entirely unmentioned” and that the film highlights “[white] female complexity at the detriment of nonwhite characters”.

Gyllenhaal hasn’t seen the article, but argues that the racial dynamic between the characters is an implicit part of the film’s messy stew of ideas. “The fact that he’s the child of Indian immigrants is a piece of the storytelling, and she has erased not only his race but his authorship,” she says. “I think in some ways that is the story that we’re telling. It’s a part of the intention of the film, as opposed to an unconscious mistake. I think that it’s a very problematic trip that we watch her go on – and race is a part of that trip.”

The Honourable Woman. Photograph: Des Willie/BBC/Drama Republic

Still, it is clearly food for thought, and, after we have moved on to another topic, she abruptly shifts back to the subject at the forefront of her mind. “I’m sorry … I’m still thinking about your last question,” she says. “I’m thinking about putting something difficult on the table and looking at the ways that people respond to it. I wonder what it would mean to have [Jimmy’s race] be more explicit – to be more of a part of the actual storytelling.”

You suspect she’ll be mulling it over for some time because that’s what she tends to do. Recently, she has had to do a lot of thinking about The Deuce, or more specifically James Franco’s role in it. During the hiatus between the drama’s first and second seasons, Franco – who plays twin brothers – was accused by a number of women of sexual misconduct at his New York acting school. (Franco denies the allegations.) There were calls for him to be removed from the show, particularly given that its subject matter concerns the abuse and exploitation of women. Yet, when the second season aired last autumn, Franco still had a starring role.

Gyllenhaal, who has been a prominent figure in the #TimesUp movement against sexual harassment and abuse, says that her thinking on Franco’s role in the Deuce “changes all the time”. She says that show’s producers checked with the female members of the cast and crew to make sure that they were comfortable working with him, and no concerns were raised. She believes that “there have to be consequences for disrespecting women sexually, or at all”, but feels that cancelling the series – as some speculated the show’s network HBO would do – would have sent the wrong message.

“The show is about misogyny and inequality in the entertainment business,” she says. “And I feel that there are all of these fascinating women telling these stories that illuminate exactly what is on the table in terms of feminism at the moment. That would have felt misguided and confused to me.”

Because, even in 2019, it is still an uphill task getting these stories made by and about women on to our screens. Gyllenhaal points to the production for The Kindergarten Teacher, a gruelling five-week shoot on a shoestring that at one point saw her “changing my clothes between scenes in the bathroom on the Staten Island ferry”.

“On one level I feel like: OK we were this group of women, of course we never expected to have enough money to make the movie,” she says. “So we just were, like: ‘On with it! Let’s make it work.’ And I feel very proud of that. And on another level, I think: ‘Why don’t we have enough money? We just needed a little more!’ And I do think that has something to do with a kind of inequality that we’ve just gotten used to.”

After all, she adds: “Nobody should ever be naked in the bathroom on the Staten Island ferry if you can help it.”

The Kindergarten Teacher is released on 8 March