Legion has always prided itself on being one of the craziest and most beautiful shows on television. But last night (April 3) the FX superhero series took that status to a whole new level by featuring a dance battle between three of its lead actors — Dan Stevens, Aubrey Plaza, and Jemaine Clement. It was a wild moment even for a show known for being totally off the wall; yet in between all of those pops-and-locks, the thrilling scene made sense for the story and actually helped propel all the characters (and the plot) forward.

To help figure out how this superpowered dance battle came to be, Decider spoke to Legion‘s creator Noah Hawley, composer Jeff Russo, and the two choreographers responsible for the dance, Richmond Talauega and Anthony Talauega.

The lead-up to the scene? Legion‘s first season ended with its mutant protagonist David Haller (Stevens) trapped in a mysterious orb. Season 2 picks up a year in the future, as David’s superhero allies work on their plan to defeat the villainous Shadow King (Navid Negahban). They’re also trying to sort through David’s memories to figure out where he’s been for the past year.

“Over the course of that first hour we realize that [David] is not telling us the whole story,” Hawley told us. “We’re getting teases of some images that he remembers including dancing, so we’re starting to give the audience a heads up that something’s coming.”

David’s scientist ally Cary (Bill Irwin) eventually hooks David up to a sensory deprivation chamber so he can revisit his memories. The dance battle (which takes place entirely in David’s memories) stands in lieu of a stereotypical “big superhero fight,” pitting the show’s hero against two of his most complicated enemies: David’s best friend Lenny (Plaza); and the co-founder of the superhero organization that saved David, Oliver Bird (Clement).

“[In the comic book genre] there’s a lot of action sequences, mostly having to do with fighting or chasing. What was interesting to me was, can you expand the definition of an action sequence?” Hawley noted. While a fight or chase scene always pits two sides against one another with a clear winner and loser, “the dance sequence, on the other hand, it’s a dance battle. It can be an act of courtship. It can be posturing — peacocking. So the dance itself has a lot more dimensions to it than pure action.”

Added Hawley, “When you realize that, why would you ever do anything but dance?”

So did the dance battle start with character, or plot? Not really: Hawley wanted to use a ’60s synthesizer this season. The showrunner envisioned Bill Irwin’s Cary plugging cords into the synthesizer to help David find the Shadow King.

“He plugs in the first cord, and he begins to make a beat, and he plugs in the second one and it begins to make some music, and suddenly that’s interesting,” Hawley said.

Unbeknownst to Hawley, Legion‘s composer and Hawley’s frequent musical collaborator Jeff Russo had already purchased a Moog modular synthesizer — exactly the kind of machine Hawley wanted.

“With every season of Legion I tend to want to buy some esoteric, cool synthesizer or some piece of gear that will be unique to that season,” Russo said. “[The synthesizer] was a really, really incredible coincidence, and yet it didn’t surprise either one of us at all.”

Russo then started writing the music for the scene. The composer incorporated Season 1’s use of electronic and organic instruments into the number, especially when constructing Lenny’s section. As he was creating, Russo kept Hawley’s notes about the dance battle in mind, making sure there was room in the piece for each character to have his or her own moment.

“Because I decided to write the piece of music before we shot, in the script it wasn’t totally specific about how it was going to look,” Russo recalled. “So I think a lot of how it ended up looking was based on how I formulated the piece of music.”

After the music was created, Hawley brought in choreographers Richmond Talauega and Anthony Talauega. “They came up with a routine and they showed it to me, and I started laughing while I was watching it because, you know, the fact that I get to write ‘dance battle’ and then they make a dance battle is so ridiculous to me,” Hawley said.

After a silent but charged confrontation with Lenny and Oliver on the nightclub floor, it’s David who starts off the dance battle. Always stone-faced, David’s moves are sharp and intense, often breaking past his circle of four backup dancers to use more space. According to the Talauega brothers, breaking from the self-imposed format of the scene was incorporated to reflect both David’s complicated history as a character and his universe-warping abilities.

“We wanted to stretch the physical anatomy to a degree,” Richmond said. “We put them all together and made sure they were contrasting each other, but we really wanted to make sure that Dan was the ish. That he was the shit.”

Good news: Stevens was, in fact, the shit. The Talauega brothers said they sometimes get nervous before a project because they don’t know if the talent can pull of the moves they want to execute. Stevens was so good at his routine, the choreographers actually made it more complicated.

“After a while you had to ask him, ‘Hey man, do you know how to dance? Because you’re picking up this stuff pretty fast,’” Richmond said.

Clement’s Oliver, on the other hand, was decidedly less serious than David or Lenny. Anthony noted that Clement’s dance was more on the “primal side,” while both Hawley and Russo highlighted that section of the score as “tribal.”

Since Clement is from New Zealand and the Talauega brothers are Samoan, Clement’s movements include some South Pacific-inspired moves as a nod to their kinship. “Some of the movements that we showed him are rooted in culture, culture that we share,” Richmond said. “It wasn’t just that what we pulled was right for him. It was right for his character, and it was right for the actual scene.”

After David and Oliver have their face-off, it’s Lenny’s turn to shine. Clad in a leotard and boots that look like they were taken off the set of Chicago, Plaza’s routine has the most gravitas of the three. She’s the only character who has a special outfit, and her very appearance forces David, Oliver, and the music itself to stop before she performs.

“We wanted her to be somewhat strong and dominating with touches of female empowerment,” Richmond said. Though to viewers she might look like a Broadway vixen out of the aforementioned Chicago, or Cabaret‘s Sally Bowles, Lenny’s sexually-charged routine was actually largely inspired by Madonna. “We used to work for Madonna, so we knew all the traits of that character.”

Despite that inspiration, Plaza’s costume wasn’t picking out until the last few days of preparation for the shoot. Initially they planned on a kind of black light design element, where the outfit would change for the dance. But Hawley felt like it was “one piece too many,” and they ultimately went for a costume that was comfortable for Plaza.

Adding to Plaza’s comfort, the perfectionist actress would, according to the choreographers, sometimes mess up slightly – but rather than run the dance again, they added what she naturally did with her body into the routine. The resulting sequence infuses Lenny’s dance with a perfect blend of sensuality and dangerous oddity that defines the character.

Oh, and lest we forget: the three-way dance battle is actually a four-way dance battle, including Bill Irwin’s mutant scientist as he dances back in his lab, separate from David’s memories but still weaved into the rhythm of the scene. Irwin is known for his work as a clown, and you can see it in the way he moves, effortlessly shifting from robotic moves to ballet-inspired steps. “We just took what he already had and just shaped it,” Richmond said.

The last moments of the sequence build to a beautiful musical swell centered on David’s face. As he aggressively dances at Lenny and Oliver, bright white light fills the blue club and wind blows around them. It’s a moment that exerts David’s overwhelming power, without diminishing the Shadow King’s hold on Lenny and Oliver.

“It has to build with wind and light elements and this idea that not only are they having a dance battle,” Hawley said, “but they’re people with heightened powers having a dance battle.”

Regardless of how David’s season long fight with the Shadow King will end, Legion has already given us one of the most unforgettable moments in Marvel television history.

“What I’ll say about my cast is they’re troopers,” Hawley added. “This show asks a lot of them.”

We’ll ask this, then: more dance battles, please?

New episodes of Legion premiere on FX Tuesdays at 10 p.m. ET.

Stream Legion "Chapter 9" on FXNOW and FX+

Stream Legion on FXNOW and FX+