The first time I talked to Mark Kleiman, a drug policy expert at U.C.L.A., was in 2002, and he explained why legalization of marijuana was a bad idea. Sure, he said, the government should remove penalties for possession, use and cultivation of small amounts. He did not favor making outlaws of people for enjoying a drug that is less injurious than alcohol or tobacco. But he worried that a robust commercial marketplace would inevitably lead to much more consumption. You don’t have to be a prohibitionist to recognize that pot, especially in adolescents and very heavy users, can seriously mess with your brain.

So I was interested to learn, 11 years later, that Kleiman is leading the team hired to advise Washington State as it designs something the modern world has never seen: a fully legal commercial market in cannabis. Washington is one of the first two states (Colorado is the other) to legalize the production, sale and consumption of marijuana as a recreational drug for consumers 21 and over. The marijuana debate has entered a new stage. Today the most interesting and important question is no longer whether marijuana will be legalized — eventually, bit by bit, it will be — but how.

"At some point you have to say, a law that people don’t obey is a bad law," Kleiman told me when I asked how his views had evolved. He has not come to believe marijuana is harmless, but he suspects that the best hope of minimizing its harm may be a well-regulated market.

Ah, but what does that look like? A few places, like the Netherlands, have had limited legalization; many jurisdictions have decriminalized personal use; and 18 states in this country have approved the drug for medical use. (Twelve others, including New York, are considering it.) But Washington and Colorado have set out to invent a whole industry from scratch and, in theory, to avoid the shortcomings of other markets in legal vices — tobacco, alcohol, gambling — that lurched into being without much forethought, and have supplied, along with much pleasure, much misery.

The biggest shadow hanging over this project is the Department of Justice. Federal law still makes felons of anyone who trades in cannabis. Despite the tolerant drift of the polls, despite evidence indicating that states with medical marijuana programs have not, as opponents feared, experienced an increase in use by teenagers, despite new moves toward legalization in Latin America, no one expects Congress to remove cannabis from the list of criminal substances any time soon. ("Not until the second Hillary Clinton administration," Kleiman says.) But federal authorities have always left a lot of room for local discretion on marijuana enforcement. They could, for example, declare that they will prosecute only drug producers who grow more than a certain amount, and those who traffic across state lines. Attorney General Eric Holder, perhaps preoccupied with scandal management, has been slow to come up with enforcement guidelines that could give the states a comfort zone in which to experiment.

One practical challenge facing the legalization pioneers is how to keep the marijuana market from being swallowed by a few big profiteers — the pot equivalent of Big Tobacco, or even the actual tobacco industry — a powerful oligopoly with every incentive to turn us into a nation of stoners. There is nothing inherently evil about the profit motive, but there is evidence that pot dealers, like purveyors of alcohol, get the bulk of their profit from those who use the product to excess. "When you get a for-profit producer or distributor industry going, their incentives are to increase sales," said Jonathan Caulkins of Carnegie Mellon, another member of the Washington consulting team. "And the vast majority of sales go to people who are daily or near-daily consumers."

What Kleiman and his colleagues (speaking for themselves, not Washington State) imagine as the likely best model is something resembling the wine industry — a fragmented market, many producers, none dominant. This could be done by limiting the size of licensed purveyors. It would help, too, to let individuals grow a few plants at home — something Colorado’s new law permits but Washington’s does not, because polling showed Washingtonians didn’t want that.

If you read the proposal Kleiman’s team submitted to Washington State, you may be a little boggled by the complexities of turning an illicit herb into a regulated, safe, consumer-friendly business. Among the things on the to-do list: certifying labs to test for potency and contamination. (Pot can contain, among other nasty things, pesticides, molds and salmonella.) Devising rules on labeling, so users know what they’re getting. Hiring inspectors, to make sure the sellers comply. Establishing limits on advertising, because you don’t want allowing to become promoting. And all these rules must account not just for smoking but for pot pastries, pot candies, pot-infused beverages, pot lozenges, pot ice cream, pot vapor inhalers.

One of the selling points of legalization is that states can take a cut of what will be, according to estimates, a $35 billion to $45 billion industry and earmark some of these new tax revenues for good causes. It’s the same tactic used to win public approval of lotteries — and with the same danger: that some worthy government function comes to depend on creating more addicts. And how do you divvy up the revenues? How much goes to offset health consequences? How much goes to enforcement? How do you calibrate taxes so the price of pot is high enough to discourage excessive use, but not so high that a cheap black market arises? All this regulating is almost enough to take the fun out of drugs.

And then there is the issue of drugged driving. Much about the chemistry of marijuana in human beings remains uncertain, in part because the government has not supported much research. So no one has come up with a pot version of the breathalyzer to determine quickly whether a driver is impaired. In the absence of solid research, some legalization advocates insist stoned drivers are more cautious, and thus safer. (Hands up if you want Harold and Kumar driving your taxi. Or piloting your airplane.) On this and much else, Washington and Colorado will probably be making it up as they go, waiting for science to catch up.

And experience tells us they are sure to get some things wrong. New York decriminalized possession of small amounts of pot way back in 1977, with the condition that there be no "public display." The lawmakers meant to assure that you partied at home, not in the parks or on the sidewalks. They did not envision that this provision would create a pretext for throwing young black and Latino men in jail. When police in New York City stop and frisk, which they do a lot in rougher neighborhoods, they order their targets to turn out their pockets and — whoa, public display, come with us, son! Gov. Andrew Cuomo is promoting an amendment to curb that abuse of power.

On the opposite coast, California demonstrates a different kind of unintended consequences. The state’s medical marijuana law is such a free-for-all that in Los Angeles there are now said to be more pot dispensaries than Starbucks outlets. Even advocates of full legalization say things have gotten out of hand.

"It’s a bit of a farce when you can watch people come out of a dispensary, go around the corner and resell their drugs," said Gavin Newsom, the lieutenant governor and former San Francisco mayor, who favors legalization. "If we can’t get our medical marijuana house in order, how do we expect voters to deal with legalization?" He is now part of a group discussing how to impose more order on California’s medical marijuana market, with an eye to offering broader legalization in 2016. And, he told me, his state will be paying close attention to Washington and Colorado, hoping somebody can, as Mark Kleiman puts it, "design a system that gets us to ‘orderly’ without getting us to ‘way too stoned.’ "