Criticism of marijuana arrests provided fuel for Mr. de Blasio’s campaign for mayor in 2013, when he won promising to “reverse the racial impact of low-level marijuana arrests.” The next year the new Brooklyn district attorney, Ken Thompson, defied the Police Department and said his office would stop prosecuting many low-level marijuana arrests.

Yet the disparities remain. Black and Hispanic people are the main targets of arrests even in mostly white neighborhoods. In the precinct covering the southern part of the Upper West Side, for example, white residents outnumber their black and Hispanic neighbors by six to one, yet seven out of every 10 people charged with marijuana possession in the last three years are black or Hispanic, state data show. In the precinct covering Park Slope, Brooklyn, where a fifth of the residents are black or Hispanic, three-quarters of those arrested on marijuana charges are black or Hispanic.

The question of how to address those disparities has divided Democratic politicians in New York. Cynthia Nixon, who is campaigning for the Democratic nomination for governor against Gov. Andrew M. Cuomo, has vowed to legalize marijuana and clear people’s arrest records. Mr. de Blasio and Mr. Cuomo have been reluctant to support the same measures.

In Criminal Court in Brooklyn on a recent Monday, the people waiting in the crowded pews to be arraigned on marijuana charges were almost all black men. In interviews, some declined to give their full names for fear of compounding the consequences of their arrests.

They had missed work or school, sometimes losing hundreds of dollars in wages, to show up in court — often twice, because paperwork was not ready the first time. Their cases were all dismissed so long as they stayed out of trouble for a stretch, an indication of what Scott Hechinger, a senior staff lawyer and director of policy at Brooklyn Defender Services, said was the low value the court system places on such cases.

Eli, 18, said he had been smoking in a housing project hallway because his parents preferred him to keep it out of the apartment. Greg, 39, said he had not even been smoking himself, but was sitting in his car next to his wife, who he said smokes marijuana to relieve the symptoms of multiple sclerosis.

“They do it because that’s the easiest way to arrest you,” Greg said.

Rashawn Nicol, 27, said officers found his female friend holding a lit blunt on a third-floor stairwell landing in a Brooklyn housing project. They backed off arresting her once she started crying, he said, but said they needed to bring their supervisor an arrest because he had radioed over a noise complaint. “Somebody’s got to go down for this,” Mr. Nicol said an officer told him. So they let her go, but arrested him.

Several people asked why the police hound residents for small-time infractions like marijuana in more violent neighborhoods, but are slow to follow up about serious crimes. “The resources they waste for this are ridiculous,” Mr. Nicol said.