There's a lot going on in BlacKkKlansman, the latest film from legendary director Spike Lee. It starts with Dr. Kennebrew Beauregard (Alec Baldwin) filming a white supremacist PSA, sputtering like a rabid dog between takes and spewing racist slander. It ends with scenes from the real-life 2017 Unite the Right rally in Charlottesville, Virginia. And in between, it sandwiches a wild true crime story that comes to life as a blaxploitation film.

The movie, which hits theaters Friday, is based on the story of black Colorado Springs detective Ron Stallworth, who in 1978 began an investigation into local Ku Klux Klan activity that ended with the chapter's dismantling. But Lee shapes his adaptation with a certain frenetic energy, eschewing traditional historical tics and instead leapfrogging across genres from comedy to police procedural, historical biopic to historical atrocity. He invokes blaxploitation — a 1970s filmmaking movement centered on black heroes battling emblems of white supremacy in black communities — as a way to underwrite the tension of the subject matter. The effect of his genre-swapping is as dizzying as it is immensely satisfying.

A film as brazenly, bluntly, unapologetically entertaining as BlacKkKlansman could only be made by a filmmaker as brazen, blunt, and unapologetic as Lee, who built a career on making incendiary cultural statements about social transgressions. More to the point, it could only be made by a filmmaker with Lee's experience. The control he exerts over his craft lets him nimbly avoid the monotone of biography. Another director would have taken Stallworth's story and shot it with overwhelming sobriety, fashioning serious subject matter into self-serious cinema, the kind that is lavished with hosannas and nominations during awards season.

Lee goes a different route. He doesn't treat the material like a joke, but he doesn't grandstand, either. We're clued into Lee's more mischievous intentions right at the jump: When we meet Stallworth as he goes for a job interview, he meets with Colorado Springs' chief of police, Bridges (Robert John Burke), and a recruitment agent, Mr. Turrentine (Isiah Whitlock Jr.). Turrentine's entire purpose in the scene, it seems, is to quote the most famous catchphrase of Whitlock's career. (Yes, it's the one from The Wire.) That's a slam-dunk laugh — and proof of Lee's goals for the film.

He keeps the laughter going. Not longer after joining the force, Stallworth, having worked his way out of the evidence room and into intelligence, responds to an ad placed in the paper by the Klan calling for members, dialing the number provided and asserting to the voice on the other line his distinct hatred for all minorities, from Jews to Italians to the Irish, but particularly black people. The room goes silent. Every officer in the joint stares in stunned disbelief at what they're hearing.

It's a bit of racial comedy that would tickle Mel Brooks. From the other side of the lens, we sense Lee is having as good a time as we are.

But BlacKkKlansman doesn't remain in that comic mode for the entirety of its two-hour runtime. There's real history for Lee to cover. At one point, Stallworth goes incognito at a Stokely Carmichael (Corey Hawkins) speech, setting up the scene where Stallworth's identity struggles — the conflict he feels as a black man wearing a badge — firmly take root. He's there to ensure that Carmichael, by this time known as Kwame Ture, doesn't inject his radical ideas into the so-called "good Negroes of Colorado Springs," as Stallworth's peers put it.

But Lee films the scene with reverence, as if he too is in Ture's audience, enraptured by his words. The frame darkens, and we see the black men and women watching Ture on stage, their faces lit gently, their expressions highlighted as they absorb messages of black beauty, black power, black validation. They're powerful words — enough to affect Stallworth, too, pushing him to consider how the color of his skin clashes with his vocation. Attending Ture's speech challenges his blackness and bifurcates him as a human: He's black; he's also a cop.

Characters we meet throughout the movie argue that there's an innate conflict of interest in serving the police as a black American. Stallworth battles with that assertion through most of the movie, fighting for selfhood as determinedly as he fights the Klan. Eventually, he joins the house in cheering Ture and in chanting words of solidarity, but his face half glows in validation and half wrinkles in uncertainty. In dramatizing the violence of racism, Lee finds room to dramatize Stallworth's individuality, too.

In the uglier moments of the film, when Stallworth and his fellow officers are embedded with the Klan, Lee manages to avoid being bogged down in obvious disgust in favor of making a more sagacious point. As the operation progresses, Jewish detective Flip Zimmerman (Adam Driver) is called on to pose as Stallworth for in-person meetings with Klan delegates Walter Breachway (Ryan Eggold); Ivanhoe (Paul Walter Hauser); and, most terrifying of all, Felix Kendrickson (Jasper Pääkkönen), a man whose forehead veins look ready to burst at any second. Lee unsurprisingly paints these men as cretins, and he understands well the impulse to deride men like Walter, Felix, and especially Ivanhoe, the drunken bumbling dimwit of the bunch.

But each joke Lee writes feels like a challenge to his viewers: Laugh if you like. These men are dumber than a bag of hammers, but they'll murder you all the same. He also understands what men like these stood for, and he knows that their ideology and activities make them impossible to laugh at for too long. In that way, Lee smartly acknowledges the Klan's legacy with sober, clear eyes — which stands in stark contrast to the way he reveres black cinema throughout the film, and most of all Stallworth. He envisions Stallworth as the kind of blaxploitation hero Stallworth himself looks up to, whether it's Richard Roundtree, Pam Grier, Jim Brown, or Ron O'Neal. He sees blaxploitation as a weapon to wield against the Klan. BlacKkKlansman puts the element of white supremacy front and center, building to a climax where the Klan is brought to heel and Stallworth walks off into the sunset a hero.

To get there, Lee cuts from comedy to calamity, jumping between black remembrances of the dead and white calls to arms against minorities. Toward the end of the film, Harry Belafonte appears as an older civil rights activist, recalling Jesse Washington's lynching in 1916; Lee flips from Belafonte to Topher Grace, playing erstwhile Klan Grand Wizard David Duke, pontificating to his subjects about the need for "true white men."

The contrast marries two kinds of grim terror: the terror of the victimized, and the terror of the victimizers. It's a juggling act that Lee sustains throughout BlacKkKlansman — and a juxtaposition only he could sustain.