DENVER—Like any farmer, Elliott Klug understands the highs and lows of living off the land. But his crop requires a rigorous effort.

To keep output going, it is harvested every week. It is also grown only indoors. And though you won't find this tip in the Farmer's Almanac, his workers believe that blaring Grateful Dead songs boosts productivity.

"We were the bad guys," says Mr. Klug, chief executive of Pink House Blooms, a 70-person operation that produces and sells marijuana to people who have a prescription for it. "Now we are still the bad guys, but we pay taxes."

Across the country, the business of growing pot is fast becoming mainstream. Eighteen states and the District of Columbia have approved the use and production of marijuana for medicinal use, including two states, Colorado and Washington, that also allow recreational use. That has spurred on a cottage industry of professional growers, with an estimated 2,000 to 4,000 businesses now producing the plant for legal purposes. Total sales: $1.2 billion to $1.3 billion last year, according to Medical Marijuana Business Daily, an industry publication.

But it turns out that trying to make a profit in this business is harder than expected. When grown and sold legally, marijuana can be an expensive proposition, with high startup costs, a host of operational headaches and state regulations that a beet farmer could never imagine. In Colorado, for example, managers must submit to background checks that include revealing tattoos. The state also requires cameras in every room that has plants; Mr. Klug relies on 48 of them.