The demand for medical marijuana in the Bay State is reaching a new high, ?according to state data, which show that nearly 2,700 people registered as patients in March — the most for any month in the oft-troubled program’s history — in a surge dispensary owners say could be driven partly by the state’s opioid crisis.

The 2,680 people the state registered as active patients last month pushed the statewide total to more than 22,500, according to the ?Department of Public Health.

No month has seen more patients enter the program in the more than three years since voters made medical marijuana legal, though it has seen similar surges, ?including roughly 2,600 ?patients, in December. That could be due in part to the program’s disastrous rollout, which hampered registration and slowed dispensary openings. The first, in Salem, didn’t open its door until last June.

The Baker administration has since made a ?series of changes, including in February, when new rules allowed patients to buy up to 10 ounces of weed ?every two months, more than double the previous limit.

The surge comes as ?debate swirls around the push to legalize and tax marijuana for recreational?use, but state officials say they see the growing ?demand for medical marijuana tied to a number of factors.

Some of those who registered may be renewals, which is required every year, health department spokesman Scott Zoback said, and the February launch of two dispensaries in Lowell and Brookline also may have an impact on drawing in new patients.

“That’s one of the things we’re seeing right now: It’s our goal to continue getting dispensaries that are in the pipeline registered,” ?Zoback said.

Though no hard data ?exists, dispensary owners also have pointed to medical marijuana as a growing substitute for prescription painkillers.

“It is likely that more ?patients are talking to their doctors about medical marijuana as an alternative,” said Kevin Gilnack, executive director of ?the Commonwealth Dispensary Association, who added that “anecdotes” from Bay State dispensaries point to “many patients choosing to replace their use of prescription opiates with the safer alternative of medicinal cannabis.”

David Noble, president of the Brockton-based In Good Health, said the ?demand at his dispensary is running “roughly 10 times” what he initially projected.

“Patients with serious medical conditions increasingly understand the relief and comfort that medical marijuana can provide,” ?Noble said in an emailed statement.

Lindsay Kalter contributed ?to this report.