The group N.W.A. emerges from the streets of Compton, Calif., in the mid-1980s and revolutionizes pop culture with their brutally honest lyrics and stories about life in the hood. (  Universal)

“Straight Outta Compton,” a drama about the rap group N.W.A., boasts instant audience appeal. Longtime admirers of the Los Angeles ensemble, which helped create West Coast gangsta rap with its confrontational lyrics and defiant, physically aggressive performance, will surely flock to this long-awaited chronicle of the band’s swift rise. They’ll be pleased by this portrait of newly minted artists as combative, wildly gifted — if not always self-controlled — young men.

But “Compton” deserves a much wider reach than the group’s hard-core fans. Thanks to eerily on-point timing and adroit direction from F. Gary Gray, this classic star-is-born story manages to transcend its own tight focus. Even viewers who think N.W.A. is an airline will probably be electrified by a story that, while succumbing to its share of hagiography, still puts its subjects in context as avatars, not just of their time and place but of our own. As the film makes clear, the unfiltered rage that got the band into so much trouble — with parental groups, federal authorities, radio stations and censorious social critics — had its roots in grim realities that are all too palpable today.

The story begins in the mid-1980s, when South Central Los Angeles was awash in crack cocaine, gang violence and the battering rams and helicopter searchlights of the city’s notoriously overzealous police department. With the help of on-screen titles, the audience is introduced to the three main players in N.W.A.’s formation and eventual success: Eric Wright (Jason Mitchell), a scrappy, bantamweight dealer at the lower level of the drug trade; O’Shea Jackson (O’Shea Jackson Jr.), a high school student who writes rhymes on the school bus while his white classmates listen to Tears for Fears; and Andre Young (Corey Hawkins), a producer friend of Jackson’s who DJs at a local club, where the manager pooh-poohs their hard-edged collaborations in favor of dance-friendly slow jams.

The audience is introduced to the three main players in rap group N.W.A.’s formation and eventual success: from left, Dr. Dre (Corey Hawkins), Ice Cube (played by his real-life son, O’Shea Jackson Jr.) and Eazy-E (Jason Mitchell). (Jaimie Trueblood/Universal Pictures)

These three young men would later become famous as Eazy-E, Ice Cube and Dr. Dre, who, along with Dre’s original partner DJ Yella (Neil Brown Jr.) and later MC Ren (Aldis Hodge), formed what would be known as N.W.A., an abbreviation for the less printable N----z With Attitudes. “Straight Outta Compton” thrillingly revisits the group’s early recording sessions and initial rise to fame. Young, green and volatile, these natural writers, performers and producers are portrayed as creatures of spontaneous instinct rather than crass calculation or cynicism. When Eazy-E joins forces with a manager named Jerry Heller, the more seasoned showman immediately sees lightning ripe for bottling. Heller happens to be played by Paul Giamatti, and as anyone who has seen “Love & Mercy” knows, when he shows up in a musical biopic, it doesn’t bode well.

The film is wildly entertaining as the members of N.W.A. go from neighborhood heroes — their singles blaring from low-rider speakers and corner boom boxes — to bona fide stars, selling out arenas and alarming older, mostly white listeners appalled at titles like “Gangsta Gangsta” and “F--- tha Police.” Perhaps most important, Gray has assembled a pitch-perfect cast to portray the band, including Ice Cube’s real-life son, who bears an uncanny resemblance to the bearish, perpetually scowling rapper.

In addition to writing and performing, Ice Cube’s scenes mostly pivot around him asking Heller and Eazy-E — with increasing suspicion — about such nagging issues as compensation, contracts and what look like secretive side deals. Meanwhile, a bearded, physically imposing acquaintance of Dre’s named Suge Knight (R. Marcos Taylor) begins to lurk in the background, a quietly menacing eminence grise whose presence grows more pronounced and malign as N.W.A. grows in stature.

Ice Cube’s contract disputes and Dre’s association with Knight would ultimately spell the end of N.W.A., which “Straight Outta Compton” illustrates, dutifully and to a fault, along with the AIDS to which Eazy-E succumbed in 1995. After a lively, engrossing, often funny first hour or so, the film begins to feel repetitive, baggy and bogged down in the factual details of Ice Cube’s dissatisfaction and Dre’s disillusionment with Knight — even with such delicious details as Dre discovering Snoop Dogg and Tupac Shakur (Marcc Rose, also flawlessly cast) and Ice Cube fooling around with a little script called “Friday.”

That little side project would prove to be his breakout role (directed, incidentally, by Gray, who can’t resist an inside joke; it’s a deathlessly funny line from the film, here delivered at the expense of a pointedly half-naked woman). Yet “Straight Outta Compton” never addresses, much less questions, the misogyny embedded in so much of N.W.A.’s lyrics. Perhaps unsurprisingly for a film produced by Ice Cube, Dre and Eazy-E’s widow, the subjects are portrayed as flawed but well-intentioned family men and visionary artists. (The last point is convincingly proved in a triumphant end-credits sequence.)

Simply as a rags-to-riches story, “Straight Outta Compton” would be an engaging ride through a storied chapter of pop culture — helped considerably by its consistently impressive ensemble of promising young actors. But the film gains meaning and emotional heft from its context — in this case, a time period bracketed by the over-policing of South Central and the beating of Rodney King and subsequent riots. There’s no doubt that N.W.A.’s stage persona was just that — a collective pose of bravado and affected, overcompensating swagger. But the film deftly illustrates the forces that pushed the group members and their colleagues to strike those poses, and why they were so valorized for pushing back, at least symbolically.

The film’s climactic scene takes place in Detroit, where N.W.A. performs “F--- tha Police” in an act of unbridled defiance (by this time they’ve come under the scrutiny of local law enforcement and the FBI, who accused the group of inciting violence). The sequence, which ends with the very violence that N.W.A.’s critics had feared, has the discomfiting dual effect of feeling both lamentable and defiant, as white and black fans alike raise middle fingers in febrile solidarity.

N.W.A.’s music might have fused seamlessly with the larger youth culture’s sense of rebellion. But there’s never been any doubt that their outrage was specific, personal and, as Gray depicts it, acutely socially aware. As enlightening as it is entertaining, as sobering as it is exhilarating, “Straight Outta Compton” reminds viewers not only who N.W.A. were and what they meant, but also why they mattered — and still do.

R. At area theaters. Contains obscenity throughout, strong sexuality, nudity, violence and drug use. 147 minutes .