Set in the grimy, trash-strewn New York of 1971, The Deuce is named after a notoriously seedy stretch of West 42nd Street that was populated by pimps and prostitutes, and home to live peep shows and porn shops. Written by David Simon, who created The Wire, and his frequent collaborator George Pelecanos, the series charts the rise of the pornography industry in New York City. Simon has said that the show is about “the commodification of women” and from the female bar staff poured into skimpy leotards by James Franco’s bar manager, Vinnie, to the violent control the pimps exert over the prostitutes they run, every woman in the show, and her sexuality, is being packaged and profited from. Maggie Gyllenhaal plays Eileen “Candy” Merrell, a prostitute and single mother who rejects street-walking protocol and refuses to be controlled by a pimp, stating that “nobody makes money off my pussy but me”.

“Somebody asked me the other day whether I thought porn was exploitative or empowering for women,” says Gyllenhaal. “At the time, I didn’t actually know how to answer. Then a couple of days later, I thought, can the answer just be: ‘Yes?’”

It is a typically nebulous answer from an actor, who, in spite of roles in mainstream films such as The Dark Knight and Nanny McPhee Returns, has spent much of her career in the independent film sector. She is famed for playing the kind of complex, unconventional women who are now increasingly emerging from the small screen; her most famous role to date, of course, was the troubled, submissive assistant to the masochistic James Spader in 2002’s Secretary. While initially wary of the extensive shooting schedules of most series, the enormous success of The Honourable Woman – the BBC miniseries that won her a Golden Globe for her role as Baroness Nessa Stein – opened up Gyllenhaal to television. With The Deuce – set to be one of HBO’s biggest shows of the year – how did she feel about the high levels of nudity the part required?

Tough viewing ... watch the credits for The Deuce.

“You know, I spent no time moralising it. I am pretty comfortable with it,” Gyllenhaal says when we meet in a slick boutique hotel on the Brooklyn waterfront. “I have never been very shy about my body, and this is something I really believe in.” She lets out a small laugh. “This is so silly, but the only place I have felt shy is imagining those people who I see when I pick up my kids from school watching it. And I have to be honest and say that I don’t think I ate any bread at all while I was making this show. When you know you are going to have to wear very short shorts all summer long, you don’t.”

The show has already been commissioned for a second season, which will jump forward to the late 1970s; while a pending third season will take place in the mid-1980s, thus charting the effects of the boom in pornography on its players over a 15-year stretch. In order to explore the intricacies of such a shrouded, changing industry, Gyllenhaal was faced with a challenge. “There is so much about sex work that is in the dark, because it’s illegal, so how do you get that information in a reliable way?” she asks.

She was directed to Annie Sprinkle, a 63 year-old writer and television presenter, and former porn actor, who had also worked as a prostitute in the early 1970s in San Francisco and New York.

“She has a support group for women who are involved in porn and prostitution,” says Gyllenhaal. “So she introduced me to this world of women in their 60s who had been, and some of whom still are, involved in sex work.” Their experiences challenged many received ideas about prostitutes as victims. “They all said: ‘Don’t write us off,’” reports Gyllenhaal. “They said: ‘Yes, there is often an element of damage [in their past].’ But there are a lot of other things too; there’s curiosity, and an actual love of sexuality. And I saw both elements.”

I am the barfly ... Gyllenhaal with James Franco in The Deuce. Photograph: HBO

And, contradictory though it may sound, in a show that features both graphic sex and violence, there is also an innocence to the trade it portrays. “Annie said that sex work then really had a different feeling about it than now,” nods Gyllenhaal. “That they were just coming out of the 1960s, and there was a celebration of freedom. People had this idea that they were smoking pot and making love.” Similarly, her ideas about pornography were transformed. “I thought of all pornography the same way, and what I realised is that pornography is an art form. And that there are actresses who are very proud of what they did in pornography.” The growth of the embryonic porn industry is seen primarily through Candy’s lens, both figuratively and literally: over the course of eight episodes, she develops an ambition not merely to star in porn films, but to direct them. “It’s like a light goes on inside her, and she starts thinking of herself as an artist,” says Gyllenhaal.

A similar shift took place with Gyllenhaal’s ambitions, too. “I wanted some kind of guarantee that I would be a part of the storytelling, part of considering what it is we want to be saying,” she says. Gyllenhaal asked for a production credit, but people around her said that given a show of this size and profile she shouldn’t expect to get one. “And I thought, ‘Well, I’m still going to ask for it.’” To her surprise her request was granted. When this happened she felt a “real shift in my sense of myself as a woman and an artist. Which was like a meta version of what the piece is about.”

As a producer, she was empowered to suggest additions to the script. For example, a deeply intimate scene in which we see Candy masturbate was Gyllenhaal’s own idea. “It wasn’t that I had a burning desire to pretend to masturbate on television,” she says, wryly. “It was that I wanted to find a way to express the difference between performative, transactional sex, and sex that is about someone’s actual desire. And I thought that was an interesting way to do it. But that was the scene I felt the most vulnerable about. Because I was trying to create something that looked and felt real.”

Pushing the envelope ... Gyllenhaal with James Spader in Secretary. Photograph: Sportsphoto/Allstar/Lionsgate

Other challenging scenes included a porn shoot in episode two in which Gyllenhaal’s character “gets Campbell’s soup sprayed on her face with a fucking turkey baster,” she says, looking suitably horrified. “I can’t actually think of anything more degrading. And I knew it was in service of having a conversation about degrading women – which we are having – but I still had to do it, and I found that very difficult.”

So far, The Deuce has been widely applauded for its exploration of the female gaze, and Gyllenhaal claims that it is “absolutely, definitely a feminist project”. But therein also lies a challenge: how to make a show about the sex trade and pornography without it becoming pornographic itself. Gyllenhaal, however, believes that is part of the show’s power and what it has in common with The Handmaid’s Tale and The Girlfriend Experience.

“If it turns you on, but then makes you horrified to consider what’s actually turning you on, and what the consequences are for the characters that are turning you on, then it’s a better show,” she says. “If you’re patting yourself on the back and just thinking how terrible porn is, then it doesn’t make you consider your position as a person in the world right now, and how sex is commodified everywhere today.”

The Deuce continues on 3 October, 10pm, Sky Atlantic