Spoiler alert: Do not read until you’ve watched episode 3 of season 6 of “Girls,” titled “American Bitch.” The episode — along with new eps of “Big Little Lies” and “Crashing” will be released earlier than usual on Friday on HBO Now, HBO Go, and On Demand.

Sunday night’s episode of “Girls” is one of the finest half-hours the show has produced — essentially a one-act short film in which Hannah (Lena Dunham) visits the apartment of Chuck Palmer (Matthew Rhys), an acclaimed author accused of sexual assault. The resulting encounter between the two of them is one of manipulation and shifting power dynamics, one that uses Dunham’s gift for reproducing awkwardness to sharpen the conclusion of the episode into a jagged, uncomfortable point. It seems almost reductive to observe that the episode addresses rape culture, consent, and the power dynamics between entitled creative men and vulnerable creative women — it is about all of this, but as evidenced by the Woody Allen portrait on the wall in the apartment, it’s also a personal topic for Dunham the filmmaker about untangling the legacies of once-respected role models. Because Dunham wrote the episode and is the only regular cast member in it, “American Bitch” evokes the Season 2 episode “One Man’s Trash,” in which Patrick Wilson played a lonely doctor who has a weekend-long romance with Hannah.

Richard Shepard directed both “One Man’s Trash,” “American Bitch,” and last season’s sublime “Panic in Central Park,” among other episodes for the HBO series; his vision is one that Dunham trusts for “Girls'” “bottle episodes,” those intimate ones that typically follow just one character on a particularly formative adventure. It’s fitting that in both “One Man’s Trash” and “American Bitch,” Hannah encounters a middle-aged man on his own well-appointed residential turf; the early episode and this episode seem to serve as thematic bookends for the show.

Variety spoke to Shepard about the process behind crafting the episode’s especially haunting images and emotional weight, including the conversations he had with both Dunham and Rhys about making “American Bitch” so memorable.

What was it like to direct something that Lena Dunham was so personally involved in, both in the script and on screen?

As a director, I’m extremely lucky to be able to direct stuff that Lena writes. The very first season of “Girls,” I was the first director on the show other than Lena — and I was the first person to ever direct something that Lena wrote that was not directed by Lena. That was a huge thing in Season 1. In Season 2, we did “One Man’s Trash,” the Patrick Wilson episode, together.  And that solidified a feeling of Lena’s that when she wrote a bottle episode, for lack of a better term, that she really enjoyed working with me, and having another voice in the room in terms of the episode.

I did the episode last season with Allison Williams, “The Panic in Central Park,” which is also written by Lena and was another episode sort of off on its own, in its own little hermetically sealed world. I think that Lena, knowing that this is the last season, had this idea for this episode and wanted to do it with me because we’ve had these bottle episodes we’ve done together before. It was a great way to close out my “Girls” experience after six years — this very intimate episode, and getting to spend so much time with Lena. Especially a piece like this, which is so intricately written and requires such intricate directing because of the acting and storytelling. I feel really lucky that she thought of me for it.

What were your conversations like when you were getting ready to set this up, with Lena and with Matthew Rhys too?

When I read the script, one of the first things I said was: “We need to hire an actor who is inherently likable.” Because we’re asking a lot of an audience with this guy — he represents something, and at first I think the audience is going to totally not like him. But at a certain point they have to start seeing at least hearing him out, so by the time Hannah goes into his bedroom they buy it, they’re not screaming at the television. In a way he warms up to her, and she warms up to him. So for me, it was important to hire an actor who was able to find a humanity in sometimes unlikeable characters.

Matthew is someone who definitely fit that bill. He’s always been able to find … You’re always rooting for him, even when he’s killing people on “The Americans.” We had heard through the grapevine that he was a fan of “Girls,” and it started to make sense.

The other thing I said to Lena was that I really would forfeit a day of filming to have just a private day of rehearsal with her and Matthew and Jenni Konner. And so we traded a day of shooting — and I was able to basically really rehearse as much as one can do in one day. We were able to talk about the scenes and really examine what they were about, and what we could do to make them more interesting, what we could do to make them funnier or more tense. Since it all took place in one apartment, we were able to block the thing. That day of just the four of us alone in that apartment really expanded everything. So when we were actually shooting we were really just focusing on the work, which at the end of the day, it was an episode in which I knew — Listen, we had nothing to cut away to. We had no funny Ray story going on. We had no Shoshanna-getting-into-trouble story. We only had this. In a way, it put a lot of tension and a lot of pressure on us, but at the same time, that was sort of fun. I was like — well, you know if we fail, we’re going to fail and it’s going to be ugly, but if we succeed, it could be something really interesting. Those are super fun risks to have. And I think Lena — sixth and last season certainly — has a confidence in herself and her writing to have a sense that this story was going to resonate.

You do keep changing your measure of Matthew’s character. By the end, I felt he’d calculated the whole situation. Was that your read on set, too?

One hundred percent. I think you had the correct response.

There was a discussion at length about whether Hannah should touch his penis — you know what I mean? At one point in the script, he pulled it out and she just got off the bed [as opposed to what happened in the final version]. And one of the things I was saying was — listen, this is at the end of the day. Hannah proves herself to be capable of a very lively discussion with him in which he is indeed impressed and she sort of holds her own with him.” In a way, he softens his opinion of her because of that — but at the end of the day he still needed to win the debate. And the debate for him, and the point to him, was that ultimately he was proving his power. Society has set up these rules, and if I pull out my penis, you’re going to touch it, because that’s almost what’s expected, of you because of the system we have. It was a power move — and it was a sh*t move — and it sort of proves his character.

Quite frankly, Matthew was so fearless in everything. It was his instinct to sort of smile on the bed after Hannah gets up and is horrified, which is a great shot. I remember in rehearsal he did that and we were — all of us were like, oh my God. It wasn’t in the script. But it was such a great reaction because he’s basically like, We’ve been playing a game of tennis but I won.

He’s very pleased with himself, and it’s galling.

It is. But I hope that the episode pushes people to think about how they were feeling towards him throughout the entire episode. So that by the time they’re sitting in the living room watching his daughter play the music — and for an episode in which there’s basically talking from the beginning until that moment, then there’s this moment where it’s just music and just the way people are looking at each other. Hopefully you can spend that time going through and saying, Would I have done this? Would I have done that? How could this have gotten to this point? And hopefully go, Wow, I get it. I hate that I get it but I get it.

Speaking of the end of the episode, the final image I thought was really haunting. Was that something that you brought to the episode, or was that already in the script? What was that like to film?

That was something that I brought to the table. But I’ve got to say this — one of the great things about working with Lena is that because she has final cut of the show, she really encourages people to think outside of the box of her script — because she ultimately knows that she can pull back if she needs to. I pitched this to her. For me, I wanted to make sure that we didn’t — because the episode is so, in a way, just a two-hander — I didn’t want it to just feel like, Okay, well it’s over. She sort of escaped the lair of this guy, probably scathed a little but basically got out better than the person that she’s talking about throughout the episode. But I didn’t want it to feel like, Okay well, she got out and it’s okay. To me it’s about a bigger picture, which is that there’s a… This guy is symptomatic of a culture that puts men in a position of power in all sorts of ways and is really dangerous because of that. I wanted to say that maybe Hannah gets out, but this is still going on, and don’t think that we’ve sort of closed the book on it.

I’ve got to say, I wasn’t 100% sure it was going to work. But when we were actually filming it, it was one of the rare times in six seasons that I’ve been doing “Girls” that I actually was like, “Lena, come watch the playback of what the shot is. Let’s look at it, because I think it’s really cool.” Then Lena was like, “It would be cool if the Rihanna song became the real Rihanna song” and there was just something … We were all very excited, by then, what that could be.

Again … I don’t know if I would have suggested this in Season 1. Not because it wouldn’t have worked for the episode, but in terms of confidence level of working with someone. In Season 1 you just hope you don’t get fired. You hope your ass is back. After six years and 12 episodes of doing “Girls,” I feel like I’m able to suggest things that Lena can not like, and I’m not offended and she’s not offended, and conversely I can suggest things and she’s like, “Wow, that’s a cool idea,” or whatever. That’s why it’s one of the most fun shows to direct on.

Did Matthew’s character change during filming? There’s a lot of set dressing in this episode about Conor that is so telling. What were you guys thinking about when you created that apartment?

I’m one of those directors who drive location people crazy because I’m like, the locations are a character. Certainly when it’s one set piece — finding that apartment was key to sort of understanding this character. This guy lives in an apartment that you can imagine Hannah dreams about, but it also has to be lived in and worn. A lot of that is in the script — like the Woody Allen painting on the wall was in the script — but then there’s a lot of things that we added to try and give it this feeling of, this is an adult and successful writer who lives here, which is what Hannah wants to be and is on the road to being.

For me, if an actor walks into a set and it feels correct to their character, you’re a long way there to getting a scene to work. It’s a weird thing. It’s like if the wardrobe is right and the set is right and if you have extras, if you’re doing a restaurant scene, if the extras are right and the guy playing the waiter is right — some of the actors start really feeling like this is as close to a reality as an unrealistic thing can be. That apartment felt so right. And Matthew came in and was like, I want to keep my beard, I want to be a little schlumpy, I’m going to play it a little depressed and a little gruff. All of that stuff, he doesn’t try to charm her. He barely smiles — he says, “That’s funny,” but he rarely smiles in the episode. All of that sort of stuff was him bringing something to it, him finding the character, him doing it. When you have a script as tight as Lena’s, you have actors who feel like they can inhabit it.

Lena as an actress forgets about herself as a writer and will improvise a lot. There was definitely improvisation between both of them — but it wasn’t necessarily about here’s a hysterical line. Her monologue about her teacher in school — there were different versions of that, and different ways it went. He had different reactions. But that’s sort of what’s fun about it, especially since we sort of knew — we’re doing this scene today. It’s a five-page, six-page scene, and you’re talking. There’s not that many camera angles. Let’s do as many takes as we can. It’s a luxury, in a way. I wanted it to be pretty precise in the camera stuff — I didn’t want it to be handheld, I wanted it to be controlled, and I wanted to really get a sense of that apartment. The paintings on the wall, we created these paintings that were like different points of view of the apartment. I wanted to just feel the apartment, and then see it in a different way. Working with Matt Munn, the production designer who is so great, and Suk Yi Mar, the locations manager who’s amazing and found that apartment, we were able to really craft the way that episode looked in a very specific way.

I loved that painting. Definitely seemed like an affectation that a rich writerly person would do in their apartment, and it made for a great shot.

That was part of the advantage of a rehearsal — because our rehearsal day was actually two weeks before we shot, and I was able to say, “I’m going to put the camera here” and say to Matt Munn, “the painting is from this point of view.” We knew where the shot was. That was an advantage of just the way we all as a team approached the episode. To take advantage of the little gifts we had that literally the producers of “Girls” were willing to let us have a rehearsal day. This is how it can pay off in so many other ways.

Listen, when you see a script that is basically 30 pages in one set — as a director, that’s like pure panic. What am I going to do to make this interesting? Can’t we blow up a car or something?. What are we going to do to kind of enliven it? Lena has always been great in that she occasionally, once or twice a season, writes an episode that has a feeling like it’s hermetically sealed in its own world, almost like a mini movie. I’ve been lucky to get a bunch of those, and they are really interesting because you can approach them in a different way. You can choose, stylistically, to shoot them slightly differently. You can choose the way you want to tell this story — because one of the things I think you almost forget, when you think about how difficult this episode is to craft from a writing standpoint, is that it somehow feels like an episode of “Girls,” even though it’s having a very interesting sort of conversation that doesn’t necessarily … Especially after the last episode, which is very funny, and does huge, broad things. To go into this and to still feel like it’s still part of the same show, that was one of the things that popped out.

He has a pretty good argument for a lot of that episode, you know what I mean? I wasn’t taking his side on any level about this. But I am a 52-year-old man coming in as a different point of view than Lena Dunham. So I brought in my own point of view about the situation and wanted to make sure that the conversation was a fair fight. Until the moment when he stopped playing fair — because he used his power in a way that sort of won his argument and destroyed his argument at the same time.

You’re directing another episode this season, right?

This is actually the last episode I directed — the last episode of Girls, the one that will air in a few weeks, is in order the last one, but not the last one I shot.

She trusted you with a particularly personal episode for her. That must be a nice coda for your time on the show.

It is. I felt really lucky. It’s been an incredible creative relationship, and I think you could speak to almost anyone who worked on “Girls” for a number of years and they would say the same thing in whatever capacity. Lena and Jenni and Judd [Apatow] were great bosses to work for because they were collaborators in the best sense of the word. They were open to good ideas and encouraged them.

It is a little sad. It’s weird that summer is not coming and I’m not doing two episodes of Girls because for the last six years I have — and it’s such a great way to spend a summer in New York, is to be shooting “Girls” on the streets of New York. You could not ask for a more New York experience than being on the street with Lena Dunham while you’re shooting an episode of “Girls” when it’s 95 degrees and everyone’s eating Italian ices. It’s like the greatest thing in the world. I will definitely miss that.