New Jersey Gov. Phil Murphy finally delivered on a 2017 campaign promise when he signed legislation Monday that legalizes cannabis for adults, decriminalizes the possession of up to six ounces of the drug and codifies criminal justice reforms that will upend how police officers interact with underage offenders.

Despite New Jersey's deep-blue political backdrop and strong tailwinds in support of loosening Reagan-era drug policies, Murphy, a progressive Democrat, came close to rejecting the measures.

Adult use is supported by the state’s two most powerful lawmakers and, three months ago, 67 percent of the state’s voters backed a constitutional amendment saying New Jerseyans aged 21 and over should be allowed to sell and use cannabis.

Even so, New Jersey’s three-year odyssey toward a regulated cannabis market nearly ran aground over disagreements between Murphy, top Democrats and leaders of the Black and Latino legislative caucuses over how to penalize kids who have been caught with a loose joint.

“There isn't anyone who has supported these efforts who wouldn't acknowledge this process has taken much longer than anticipated, but certainly it is better to get things done right rather than fast,” Murphy said during a press briefing on Monday, thanking Democratic lawmakers who “kept working and talking even when things ground to a halt.”

Murphy’s comments came an hour after the noon deadline for action on both a legalization measure NJ A21 (20R) and a decriminalization bill NJ A1897 (20R), that were sent to his desk Dec. 17. It wasn’t until the Legislature on Monday morning passed a third bill addressing underage penalties, NJ A5342 (20R)/NJ S3454 (20R) — with just 20 minutes to spare — that Murphy affixed his signature to all three.

Thus, New Jersey became the 15th state to approve cannabis for recreational purposes.

“This process may have had its fits and starts, but it is ending in the right place,” the governor said.

The “right place“ is unloved by almost everyone involved.

“No one is happy, and nothing is perfect. And let’s not let the pursuit of the perfect be the enemy of the good,” Sen. Nicholas Scutari (D-Union), the cannabis bills’ lead sponsor, said shortly before the upper house voted, 23-12, to send the bill to the governor. “This is a topic that needs to be put behind us.”

The protracted debate over underage penalties ground the Legislature to a halt. The Assembly pushed back scheduled quorums twice to provide more runway for negotiations, frustrating lawmakers who thought they had finished work on cannabis legislation when they sent the legalization and decriminalization bills to Murphy in December.

Even though Murphy’s team had worked closely with lawmakers on both the legalization and decriminalization bills, it wasn’t until after their passage that administration officials discovered inconsistencies in the legislation they interpreted as legalizing cannabis for children.

Under the legalization bill, those 21 and younger caught with less than 1 ounce of cannabis could be charged with a petty disorderly persons offense. But the decriminalization bill removed penalties for those under 21 caught possessing marijuana — a term that would only apply to illicit products.

Some in the Legislature insisted those decisions were deliberate, noting it would discourage police interactions within minority communities where drug laws are disproportionately enforced. Murphy pushed back, telling reporters “nobody has ever, including yours truly, spoken about legalizing marijuana, recreational marijuana for kids. That's never been in the cards.”

Shortly before the New Year, the administration requested that lawmakers pass a third, “clean-up” bill that would clarify underage penalties, triggering more than two months of intense negotiations that collapsed repeatedly as the state’s Democratic leaders struggled to reach a consensus on how to discourage underage drug use without being overly punitive.

By early February, as talks sputtered, Murphy was preparing conditional vetoes for both the legalization and decriminalization bills, a move that would have taken an axe to one of his signature policy initiatives and further alienated him from Democrats in the Legislature.

It wasn’t until late last week that Senate Democrats started to reach a consensus on language that would salvage the legalization drive.

Under the adopted language, minors found in possession of both cannabis and alcohol would be subject to a series of formal, escalating warnings that could culminate in a referral to a community organization for counseling or other services.

In addition, law enforcement officers could be found guilty of depriving residents of their civil rights if they’re found to have violated new rules dictating underage possession. The odor of cannabis or alcohol will no longer be enough to justify a search. The same holds true for “the unconcealed possession” of an alcoholic beverage, marijuana, hashish or cannabis item, according to the bill text.

“When people blanched at the idea that this was solely about money from recreation, and talked through the idea that this was about social equity and activism, this was our collective opportunity — all of us — to actually put words into action,” said Sen. Troy Singleton (D-Burlington), who played a key role in forging the compromise measure. “That’s how a lot of the principles in this clean up bill were framed.”

While the clean-up bill attracted adequate support in the Senate, some lawmakers were holding their nose as they voted ‘yes’.

Republicans objected strenuously to the bill and New Jersey’s powerful Policemen’s Benevolent Association called it “anti-police”. Meanwhile, some of the state’s leading Black lawmakers, including Legislative Black Caucus Chair Ron Rice and Sen. Nia Gill (both D-Essex), said the legislation didn’t go far enough to hold law enforcement to account.

“We bungled this process.” Sen. Paul Sarlo (D-Bergen) said during Monday’s debate. “Before the legislation is even signed, we’re doing our first clean-up bill.”

Even so, lawmakers and administration officials expressed relief on Monday that New Jersey had finally, conclusively put to rest legislation that Murphy had anticipated signing more than three years ago within the first 100 days of his term.

While work in the Legislature is mostly done — Scutari said more clean-up legislation is likely — New Jersey is still several months away from seeing its first legal sale of cannabis.

Certain provisions of the decriminalization bill took effect immediately — cold comfort to the thousands of New Jerseyans who have been arrested for possession since the constitutional amendment passed on Nov. 3 — but implementing the legalization measure will take at least six months, Murphy said Monday.

The newly-formed Cannabis Regulatory Commission, which is tasked with overseeing both the adult use and medical marijuana markets, needs to develop rules that will dictate the distribution of dispensary and cultivation licenses.

The awarding of licenses will come with its own timeline and, while existing medical dispensaries can sell recreational products under the new law, they don’t have enough supply to meet the needs of the state’s 100,000 registered patients.

Whatever economic boom New Jersey officials might have expected from being the first adult use marketplace between Washington, D.C., and Boston likely won’t be realized for years. And even then, as lawmakers in New York, Connecticut and Rhode Island launch their own bids to legalize recreational marijuana, whatever benefit New Jersey would accrue may be muted.

“We’ve gone too far long without any action and, look, based on the numbers, we’ve lost the opportunity to create jobs, we’ve lost revenue,” Ed DeVeaux of the New Jersey CannaBusiness Association said in an interview late last week, adding that a reported 6,000 people have been arrested for cannabis since New Jerseyans voted to legalize the drug in November. “We’ve continued to hurt people.”