Jamine Richards (l.) protests at a Los Angeles Police Commission meeting in August in downtown Los Angeles. Dozens of protesters interrupted the meeting on the anniversary of the fatal shooting of Ezell Ford by police.

Los Angeles — When Jesus Naranjo was stopped by the California Highway Patrol at 1 a.m. two months ago, he says he was listening to music on his Beats headphones. The officer asked Mr. Naranjo to show him what he was doing. When he reached for his music player, he says, the officer reached for his gun.

Naranjo said he froze and the officer backed off his weapon. But that didn’t conclude the stop. He was taken out of his car, patted down, and questioned. After he told the two officers that he worked nights at a gym while going to college for business, he says the officers told him to drop and “give them 20.”

Naranjo dropped to the pavement and began counting push-ups. By the time he reached 12, Naranjo realized the officers were walking away. They said nothing more to the 20 year-old Latino, but Naranjo could hear them laughing as they left.

While the above encounter led to no further action by the officers, under a new law signed by Gov. Jerry Brown Saturday, law enforcement all over the Golden State will have to document the race or “perceived ethnicity” of suspects in any such stop or arrest. The law is one of the toughest in the nation, aimed at creating, and making public, a database of information that can be analyzed for potential patterns of racial profiling.

The legislation – more than 15 years in the making – was opposed by numerous law enforcement groups even as it was hailed as historic by civil rights activists. It comes at a time when cities across the United States are wrestling with questions on how to best protect people while not infringing on the rights of minority citizens. Advocates say that it goes further than almost any other state law, requiring documentation for any encounter between police and the public, whether pedestrian or automotive, and whether or not the encounter results in an arrest or citation.

“Racial profiling has been a national crisis for people of color for decades,” says Najee Ali, executive director of Project Islamic H.O.P.E. in Los Angeles. “Now we finally will have some proof with the collected data to back up some of their claims.”

But that very comprehensiveness was cited by both the California Police Chiefs Association and the California Fraternal Order of Police in their opposition to what one spokesman called a “terrible piece of legislation.” According to a statement issued by the Fraternal Order, the added paperwork would take “peace officers away from response, patrols and building relationships.”

To them, the new law is a bureaucratic nightmare designed to address a problem they say does not exist on the ground.

“There is no racial profiling. There just isn’t,” Lt. Steve James, the national trustee for the California Fraternal Order of Police, told the Los Angeles Times. “There is criminal profiling that exists.”

Such claims are not borne out by the evidence collected in other states that have passed similar legislation, says University of Kansas researcher Charles Epp. He is co-author of a study of the social effects of investigatory police stops. Missouri has had a data collection law on the books since 2000. The law was implemented both easily and effectively, notes Mr. Epp. But more important, he says the data show clear patterns.

“It’s very clear from the numbers they were using stops as a means to check someone out,” he says. “It seems clear that California data this law will produce will allow watchdog groups to see if this is happening in California.”

Adds Epp, “I will be very surprised if it isn’t.”

California is the latest state to enact legislation to tackle racial profiling. The US Department of Justice updated its policies on racial profiling in December, banning the practice for many federal agencies such as the Federal Bureau of Investigation. Nearly every state has considered some form of anti-racial profiling legislation in recent years, while at least 18 have laws requiring some form of data collection related to racial profiling, The New York Times reported in June.

At least California’s largest police department will not be starting from scratch. The Los Angeles Police Department (LAPD) operated under a consent decree from 2000 to 2013 under which it was required to collect racial data and has continued the practice, a spokesman says.

“There was some resistance at first,” says LAPD Commander Andrew Smith, “but we enter it on the computer now and it’s pretty simple.”

It will be years before the California data begin to come in: Large departments must comply by 2019 while smaller ones have until 2023. Until then, activists say they will continue to rely on anecdotal evidence such as those recounted by 18-year-old Malik Baker.

The African-American college freshman says he was driving home at 10 p.m. in September, when a police car pulled him over near his home in Van Nuys.

“The cop just asked me who I was and what I was doing,” he said. “I wasn’t doing anything but going home after shopping,” says the teen, who is a freshman at Los Angeles Valley College, studying kinesiology.

At first, Mr. Baker says he has little confidence that the law will do anything to change police behavior.

“The cops do what they want,” he says.

But upon reflection, he adds, “Maybe if they know they have to be accountable in writing, it will change their behavior just a little.”