Illinois is poised to legalize marijuana sales with sweeping legislation that would also automatically expunge the criminal records of people convicted of minor pot possession.

State lawmakers gave final approval to the bill Friday and Gov. JB Pritzker said he will sign the measure, which make Illinois the first state to legalize marijuana sales via its legislature. Most other states that have legalized cannabis did so via a ballot initiative process. Vermont's legislature legalized cannabis but prohibited commercial sales.

"This will have a transformational impact on our state, creating opportunity in the communities that need it most and giving so many a second chance," Pritzker said in a statement. "In the interest of equity and criminal justice reform, I look forward to signing this monumental legislation."

Marijuana remains illegal at the federal level, but federal prosecutors have since 2014 generally ignored marijuana sales in 10 states that had already legalized it: Alaska, California, Colorado, Maine, Massachusetts, Michigan, Oregon, Nevada, Vermont and Washington, along with the District of Columbia.

Prizker's office didn't give a timeframe for when he might sign the law, which would go into effect Jan. 1, 2020. Under the system, adults could buy and possess up to 30 grams of cannabis "flower," along with marijuana-infused foods known as edibles, and small amounts of highly concentrated extracts. Non-residents could buy half the amount.

The law also establishes a system for taxing and regulating marijuana, and consumers would pay up to 34.75% tax on their purchases, depending on potency. Regulators would give preference points to members of minority groups seeking to get business licenses, and state-certified labs would test products for potency and contaminants, a growing concern among users. Backers say the measure will create jobs in communities around the state, an argument made by Canadian officials when they legalized marijuana nationally last year.

Money raised by the new taxes would first be dedicated to expunging an estimated 770,000 minor cannabis-related cases, according to the bill's language. Expungement has long been a goal of marijuana-legalization advocates, who argued the federal government's so-called War on Drugs disproportionately targeted minorities. Other states have similar provisions, usually added after the fact, but Illinois' law is the first to contain such a sweeping expungement provision from the start.

Any tax money left over after would be used to support drug-treatment and enforcement programs, improve mental health counseling access, and bolster the state's general fund.

"Cannabis was at the heart of our nation's disastrous War on Drugs. This is a measure that will improve people's lives on a level commensurate with the devastation wrought by prohibition," said Steve Hawkins, executive director for the pro-legalization Marijuana Policy Project, which worked with lawmakers and Pritzker to write the law. "Illinois is on the brink of replacing a shameful, destructive policy with the most far-reaching cannabis law ever enacted."

Several other states had considered but ultimately declined to act on legalization this year, including New York and New Jersey. Pritzker, who took office in January, campaigned on a platform that included cannabis legalization. His cousin is a member of the MPP board and an investor in multiple cannabis companies, although the governor's office said the two men haven't discussed legalization recently.

Anti-legalization groups had fought the Illinois proposal and promised they weren't done opposing it. "Tough to win in a state where the Gov shares the same last name as MPP’s chair," tweeted Kevin Sabet of the group Smart Approaches to Marijuana. "But there’s more to come. We’re not going to let the Land of Lincoln go to pot just yet."