Inside a small, suburban industrial building in Walled Lake, scientists in white lab coats look at marijuana under microscopes, noting every instance of mold or mites before sending the samples to be tested for potency and quality.

For five years, Iron Laboratories LLC has been filling a niche in Michigan's medical marijuana industry: Testing products for impurities and ensuring that the level of THC, the active chemical in marijuana, matches what is advertised, even though Michigan doesn't require such testing.

That's about to change. By December 2017, new licensing regulations will make safety testing mandatory, which is likely to ramp up competition. Gov. Rick Snyder's administration is expected to hire a vendor to run a statewide marijuana tracking system. And the regulations will add certainty for companies that have been operating in legal gray areas.

"I'm in a good position. I can show the state three years' worth of test results (to say): 'I deserve a license,' " said Howard Lutz, Iron Laboratories' CEO.

The gradual march in the U.S. toward legalization of marijuana represents a new opportunity for entrepreneurs like Lutz looking to start companies in a market that could top $7 billion this year, according to some national estimates. A new layer of business is forming in Michigan and across the country to support the growers and dispensaries long thought of as its central players. Tech firms, science labs, business consultants and attorneys are opening their doors to the industry — medicinal or recreational, depending on the state — without, in some cases, ever handling the drug.

Michigan is one of 25 states, along with Washington, D.C., and the U.S. territories of Puerto Rico and Guam, to decriminalize marijuana use for medical reasons, according to the National Conference of State Legislatures. California was the first state to allow medicinal uses of the drug through a voter-approved initiative in 1996.

Voters in just four states — Colorado, Washington, Oregon and Alaska — and Washington, D.C., have legalized recreational use of small amounts of marijuana for adults. The issue will be on the ballot in at least five states next month, including Arizona, California, Maine, Massachusetts and Nevada.

Still, eventual legalization in Michigan is not guaranteed. Though the issue has made it onto the ballot in at least five states next month — though not in Michigan — cannabis entrepreneurship remains a high-risk, high-reward gamble that public opinion will continue to move toward legalization. And while sentiment seems to be shifting, operating during a time of transition is complex.

Several states said they want to professionalize an industry that otherwise would be underground. People with experience in software development and biochemistry who could work in any number of fields are choosing to work in cannabis, despite difficulty in securing financing from traditional lenders and the risk inherent in operating on the edge of legality.

Companies like Iron Laboratories say their forays into the industry are in anticipation of stricter state regulation and, eventually, full legalization, which they consider the next wave of social change — one they hope to capitalize on.

"I'm not some flag-waving, free-the-weed marijuana proponent," said Lutz, who co-founded the company in 2011 after an earlier career in his family's newspaper distribution business. "I think that there's legitimacy in what we do, and I think there's legitimate opportunities here."

Some law firms are creating cannabis practice areas to advise their industry clients on such issues as intellectual property related to branding and labeling, tax law, business formation and zoning rules. Lawyers also help navigate the fuzzy line between federal prohibition and state decriminalization.

For instance, said Doug Mains, a Lansing-based attorney in Dykema Gossett PLLC's cannabis group, can a company get a trademark on a logo that uses an image of a marijuana leaf? How does an attorney advise a client on compliance with state law when that same attorney knows the advice also violates federal law?

The U.S. Department of Justice in 2014 issued guidance meant to deter some prosecution under the federal Controlled Substances Act — which bans marijuana on the basis that it has "no currently accepted medical use" — in states that have decriminalized use, but the Obama administration has stopped short of relaxing its classification of marijuana as an illegal drug with no acceptable medical use.

Marijuana businesses need the same types of legal services as non-cannabis companies, Mains said, but the legal dichotomy means "everything's a little bit more complicated."