Straight Outta Compton” hit all the right notes, earning an impressive $4.96 million on Thursday night, while Guy Ritchie’s “The Man From U.N.C.L.E.” grossed $900,000.

The first “Compton” box office figures follow recent forecasts for a dominant opening weekend of more than $40 million.

Universal’s music biopic about the iconic rap group N.W.A has been generating strong interest among African-American and Caucasian male audiences. The title is taken from the group’s debut 1988 album.

“Compton,” directed by F. Gary Gray, is launching in approximately 2,755 North American theaters on Friday after showing on 2,264 screens Thursday. O’Shea Jackson Jr. plays his father, Ice Cube, while Corey Hawkins stars as Dr. Dre and Jason Mitchell plays Eazy-E. Producers are original N.W.A members Ice Cube and Dr. Dre, along with Gray, Tomica Woods-Wright, Matt Alvarez and Scott Bernstein.

Law enforcement agencies increased their presence at theaters for Thursday night’s opening as a preventative measure ahead of the official launch of the film, which includes scenes of gang violence and police harassment — including a re-enactment of a 1989 concert in Detroit where the band performs their song “F— tha Police.”

The $29 million film, co-financed by Legendary, is opening in the wake of demonstrations against police tactics in Ferguson, Mo., and the July 23 killings of two movie patrons at a Louisiana theater showing of “Trainwreck.”

Reviews have been strongly positive with an 87% “fresh” rating on Rotten Tomatoes. “Compton” now represents more than 70% of weekend ticket sales on the Fandango online ticket site.

Warner Bros. is expecting a more modest launch from “The Man From U.N.C.L.E.,” which stars Henry Cavill, Armie Hammer and Alicia Vikander, is set in the 1960s against the backdrop of the Cold War.

The opening estimates range from $15 million to $20 million — a moderate start for a film with a $75 million price tag. “U.N.C.L.E.” is expected to perform well among female moviegoers at 3,638 U.S. locations. Reviews have been 67% positive of Rotten Tomatoes.

The Europe-set spy thriller is also opening in about 40% of the international market this weekend, including the U.K., Australia and Germany.