Sarah Gertrude Shapiro’s show takes aim at sexism and competition among women. Illustration by Malika Favre

For three years, Sarah Gertrude Shapiro worked as a producer on the reality show “The Bachelor.” Her task, as she recalls it, was to get the contestants to “open up, and to give them terrible advice, and to deprive them of sleep.” She sees it now as “complicated manipulation through friendship.” To insure that intense emotions were captured on camera, she sometimes misled contestants who were about to be rejected. “The night they were going to get dumped, I would go to the hotel room where they were staying and say, ‘I’m going to lose my job for telling you this, but he’s going to pick you—he’s going to propose,’ ” Shapiro said. After the contestant left the set, disconsolate, Shapiro joined her in a limousine while the stereo played a song that the contestant had been primed to see as “ ‘their song’ for their love story with the Bachelor.” Shapiro kept jalapeños or lemons hidden in her jacket pocket—dabbing something acidic in her eye allowed her to cry on cue, which helped elicit tears from the contestant. “I’d have arranged with the driver to have the song play just until I got a shot of her crying—then cut the music so I could start the interview,” Shapiro explained. “They’d often tell us to drive up and down the 405 until the girls cried—and not to come home if we didn’t get tears, because we’d be fired.” In hindsight, Shapiro said, being fired “would have been a great solution to my problems.”

A decade later, “Unreal,” a diabolically entertaining drama based on Shapiro’s experiences in reality TV, became a surprise hit on Lifetime. Shapiro, who is thirty-eight, constructed a scenario that teasingly mirrored “The Bachelor,” which airs on ABC. “Unreal” chronicles the making of a show-within-a-show, “Everlasting,” in which twenty women compete for a handsome man’s hand in marriage. An oleaginous master of ceremonies narrates the process. In both “Everlasting” and “The Bachelor,” the hopefuls gather at a mansion whose brittle elegance feels claustrophobic; in each show, unrealistically fit women offer “confessions” in one-on-one interviews that feel staged. In the twentieth and most recent season of “The Bachelor,” the contestants included Amber, Becca, and four Laurens. In the second season of “Unreal,” which began airing on June 6th, the “Everlasting” candidates included Brandi, Haley, and Dominique.

“Unreal” focusses on the producers who pull the contestants’ strings, and Shapiro’s pleasure in the abhorrent gives the series its darkly comic tone. The stars of “Unreal” are a caustic “Everlasting” producer named Quinn and her ambivalent deputy, Rachel, whose character clearly owes a lot to Shapiro. The relationship between Quinn, played by Constance Zimmer, and Rachel, played by Shiri Appleby, brings to mind that of Fagin and Oliver Twist. Rachel keeps trying to escape “Everlasting,” and Quinn thwarts her every time. She threatens Rachel with lawsuits, she lavishes her with praise, she threatens to expose a tryst. The first season ends, inevitably, with Quinn and Rachel alone together. “I love you, you know that?” Rachel says to her tormentor and best friend. “I love you, too, weirdo,” Quinn says. In Shapiro’s hands, Quinn—who has been denied her fair share of the show’s profits by venal male colleagues—and her protégée emerge as antiheroes, and beneath the giddy parody “Unreal” offers a singular meditation on stardom, media mendacity, sexism, and competition among women. One of the nicest surprises about “Unreal” is the sneaky way the contestants emerge as sympathetic—behind the scenes of “Everlasting” one sees the humanity that the producers suppress onscreen.

One day in February, Shapiro sat with the show’s writers in an office on the Sunset Gower lot, in Hollywood, and began imagining the futures of Quinn and Rachel. Alex Metcalf, a supervising producer, explained to me that in a show’s second season “you have to raise the stakes.” The first season had wrapped its provocations around love triangles and other familiar soapy elements. Though “Unreal” was subversive, it provided the pleasures of the genre it satirized: the fictional bachelor on “Everlasting” was as chiselled as the real ones on “The Bachelor.” This pleased the executives at Lifetime, which is best known for women-in-peril movies. In 2013, Shapiro, an unknown who lacked an agent, sold “Unreal” to the network after a friend walked her into the office of a studio executive there. Shapiro presented a twenty-minute short that she’d made, “Sequin Raze,” which centered on a reality-show producer. She recalls her pitch for “Unreal” as “A feminist working on ‘The Bachelor’ has a nervous breakdown.” Executives at Lifetime offered to buy the idea immediately. Afterward, Shapiro had second thoughts worthy of a victorious “Bachelor” contestant: “I was calling 411, asking, ‘Do you have the main number for HBO?’ ” She couldn’t reach any executives there—this is her story, anyway—and she proceeded with Lifetime. The first shot of the pilot episode—Rachel seen through the moonroof of a limousine, passed out on the car’s floor, wearing a “This Is What a Feminist Looks Like” T-shirt—caused a conflict with the network. It evoked an art film, not a sudsy entertainment. “I had to fight for it all the way through,” Shapiro remembers. “I told a lot of people to fuck off.” Lifetime wasn’t sure of the match, either: its head of research found the show-within-a-show conceit too dizzying.

Since then, the partners have grown more comfortable with each other. “Unreal” has won a Critics’ Choice Award and a Peabody Award, and Lifetime is thrilled to have an acclaimed show that attracts a hipper audience. Shapiro wants to build on her success by aiming the series more directly at the kind of viewer who admires such challenging shows as “Girls” and “Transparent.” The studio has a more conventional ambition: Season 1 averaged 3.7 million viewers an episode—paltry numbers. Lifetime is determined to transform “Unreal” into a ratings hit. “We’re seeing Season 1 as almost the pilot,” Nancy Dubuc, the C.E.O. of A+E Networks, which owns Lifetime, told me. Shapiro believes that she can accomplish both goals, and has transferred this desire to her alter ego. In the writers’ room, she described Rachel’s motivation in Season 2: “It’s really about ‘I’m savvy enough and smart enough that I know I have to give the network all the frosting and the froufrou and all the titties that they need, and in the process I’m going to slip them this super-important thing.’ ”

On whiteboards, Shapiro and her writers had sketched out a pointedly different trajectory for Season 2. This year’s bachelor was African-American—a dig at the fact that “The Bachelor” has never had one—and one of the contestants is a Black Lives Matter activist. Another is a Southerner who wears a bikini with a Confederate-flag pattern. The story line culminates in a tragic turn. Shapiro was proud to have found a way to insert the national debate about race into her seemingly lightweight show.

Lifetime executives had not objected to the race theme, but they pressed for more of what had worked last time: romantic complications for Rachel. To supervise the writers, they had brought in a showrunner named Carol Barbee. Shapiro has the reality-TV-show habit of thinking of people in epithets, and to her a showrunner is a Wubby—slang for a child’s security blanket. A Wubby is there, in part, to insure that scripts are written on time and that scenes won’t be too costly to shoot. Shapiro calls herself the Magical Unicorn—“the voice of the show, throwing up rainbows all over the board.”