Funding shortages have long plagued gun violence prevention groups in Chicago. Cure Violence, which uses outreach workers to mediate street disputes and prevent retaliatory violence, was forced to slash staff and close 13 out of its 14 offices after its state funding evaporated in 2015. Groups like Cure Violence rely largely on private donors to stay in operation, but that money is inconsistent, and too scarce to support the level of intervention that providers say is needed in a city where annual shootings consistently measure in the thousands.

Now, gun violence prevention groups may have found a boon in an unlikely source: legal weed. Last month, Illinois lawmakers approved legislation to legalize recreational marijuana. The bill earmarks a sizable share of the state’s expected profits to anti-violence efforts in underprivileged neighborhoods. Service providers say the move could inject tens of millions of dollars into struggling community programs, greatly expanding opportunities for at-risk Chicagoans and potentially reducing gun violence. The state’s new Democratic governor, J.B. Pritzker, has been a vocal champion of marijuana legalization and is expected to sign the bill.

“This could have a huge effect on violent crime rates and give Chicago a second opportunity to really be the world-class city that we know that it is,” said Monique K. Shelton, a program manager with the Centers for New Horizons, a community group. “We’re on the cusp of something really spectacular.”

The Centers for New Horizons is one of several organizations partnered with READI Chicago, a program that connects young people on the South and West sides affected by gun violence with employment opportunities, therapy, and an array of other services. Last month, participants in READI traveled to Springfield and met with lawmakers to advocate for the marijuana bill, arguing that the added funds would help that program and others like it reach more people.

Creating a new funding stream for violence prevention work was a major focus of the marijuana legalization debate, with some lawmakers refusing to give support unless revenues were steered to troubled neighborhoods. The bill was also pushed by READI and a constellation of other service providers that in February launched the inVEST campaign to highlight how little in public funding went to anti-violence programs. Last month, hundreds of activists — some wearing bright orange T-shirts emblazoned with the inVEST logo — staged a demonstration outside the state Capitol.

The legislation would allow the state to use marijuana revenues to pay for the implementation, administration, and enforcement of the new law, as well as costs associated with vacating convictions for cannabis-related offenses. Twenty-five percent of the remaining funds would go to the Restore, Reinvest, and Renew Program, under which community groups operating in so-called R3 Areas could apply for grants. R3 Areas would be designated based on rates of unemployment, poverty, and gun injury, among other factors. The program would be overseen by a board made up of state officials as well as violence prevention experts, service providers, and formerly incarcerated individuals.

Sharone Mitchell Jr., deputy director of the Illinois Justice Project, a criminal justice reform group, said that the R3 program would mark a significant departure from the state’s over-reliance on policing and prop up groups shown to be effective in stopping gun violence before it happens. He added, “This is the first time that the state government has approached violence reduction in this way, and it’s incredibly exciting.”