Communities across the United States are reconsidering the public safety benefits of prosecuting nonviolent misdemeanor offenses. So far there has been little empirical evidence to inform policy in this area. In this paper we report the first estimates of the causal effects of misdemeanor prosecution on defendants' subsequent criminal justice involvement. We leverage the as-if random assignment of nonviolent misdemeanor cases to Assistant District Attorneys (ADAs) who decide whether a case should move forward with prosecution in the Suffolk County District Attorney's Office in Massachusetts. These ADAs vary in the average leniency of their prosecution decisions. We find that, for the marginal defendant, nonprosecution of a nonviolent misdemeanor offense leads to large reductions in the likelihood of a new criminal complaint over the next two years. These local average treatment effects are largest for first-time defendants, suggesting that averting initial entry into the criminal justice system has the greatest benefits. We also present evidence that a recent policy change in Suffolk County imposing a presumption of nonprosecution for a set of nonviolent misdemeanor offenses had similar beneficial effects: the likelihood of future criminal justice involvement fell, with no apparent increase in local crime rates.