During several weeks of rehearsal in the build-up to shooting “The Favourite,” the core cast members, including Nicholas Hoult, would run scenes, play acting games and dance, while director Yorgos Lanthimos and writer Tony McNamara looked on. After only two days of frolicking around, McNamara says he earmarked Hoult to play a lead role in his next big period project, Hulu’s darkly comic “The Great.”

“I rang the other producer on the show and I said, ‘I think I’ve found our Peter,’” McNamara says. “Nick hadn’t done TV in a long time — [not] since ‘Skins’ — but I sent him the script and he was like, ‘Yep, let’s do it.’ During ‘The Favourite,’ we were already thinking what else could we do together; it was just a good partnership straight away.”

What McNamara saw in Hoult, he says, was an ability to turn on a dime between goofy comedy and terrifying rage, precisely what was required to play the erratic Peter III in “The Great.”

The two spent a long time discussing the arc that Hoult’s character would take throughout the first season, going from hated monarch to someone for whom the audience “perhaps has some sympathy,” as Hoult puts it.

“I wanted a really interesting relationship between Peter and Catherine which would grow and evolve. With Peter, there’s a question of, ‘Can he change — can he find something else in him?’ I felt like Nick could bring all of that and never lose the comic edge of the show. He has an ability to be silly almost — you’re sort of dismissing [him] one moment because he’s so funny and ridiculous, and then he has moments in the show where he’s so scary. If Nick could bring that, then you understood why the court and the whole society was the way they were. It rested a lot on Nick’s ability to do those things,” McNamara says.

Meanwhile, the first thing Hoult thought about McNamara was, “This guy writes the best dialogue I’ve ever read.”

“Scripts changing on set is something you get used to in this game, but with Tony’s work it’s always in great shape when it’s given to you,” he explains.

Hoult says he found himself falling immediately in step with McNamara’s humor, and developing a penchant for his quirky scenes involving animals, dancing and decapitated heads.

“Each line of dialogue was just hilarious, the rhythm of it, the turns of phrase, the bluntness, but also this witty, fast-paced humor that gets a lot of story in, but also has a sucker punch of emotion that sneaks up on you. You’re just enjoying a fun read and well-written dialogue, and suddenly you end up in these emotional pits,” Hoult says.

Both McNamara and Hoult agree that their creative partnership would never have blossomed as it has if it weren’t for the other players around them, namely the dynamite trio of Emma Stone, Olivia Colman and Rachel Weisz in “The Favourite,” and Elle Fanning, who plays the titular Catherine the Great, Peter’s wife, in “The Great.”

“There were times when I would give Nick and Elle a six-page two-hander only a few days before shooting, and they got excited by that,” McNamara says. “I feel incredibly lucky as a showrunner to have actors like them on my team.”