ALBANY – Joining a growing group of states that have loosened restrictions on the use of marijuana, Gov. Andrew M. Cuomo plans this week to announce an executive action that would allow limited use of the drug by those with serious illnesses, according to state officials.

The turnabout by Cuomo, who had long resisted legalizing medical marijuana, comes as other states are taking increasingly liberal positions on marijuana – most notably Colorado, where thousands have flocked to purchase the drug for recreational use since it became legal to do so Wednesday.

Cuomo’s plan will be far more restrictive than the laws in Colorado or California, where medical marijuana is available to people with conditions as mild as backache. It will allow 20 hospitals across the state to prescribe marijuana to patients with cancer, glaucoma or other diseases that meet standards to be set by the state Department of Health.

While Cuomo’s measure falls well short of full legalization, it nonetheless moves New York, long one of the nation’s most punitive states for those caught using or dealing drugs, a significant step closer to policies being embraced by drug-reform advocates and lawmakers elsewhere.

New York hopes to have the infrastructure in place this year to begin dispensing medical marijuana, though it is too soon to say when it will actually be available to patients.

Cuomo’s change of heart comes at an interesting political juncture. In neighboring New Jersey, led by Gov. Chris Christie, a Republican whose presidential prospects are talked about even more often than Cuomo’s, medical marijuana was approved by his predecessor but implemented only after he put in place rules limiting its strength, banning home delivery and requiring patients to show that they have exhausted conventional treatments. The first of six planned dispensaries has already opened.

For Cuomo, a Democrat who has often found common ground with Republicans on fiscal issues, the sudden shift on marijuana – which he will announce Wednesday in his annual State of the State address – was the latest of several instances in which he has embarked on a major social policy effort sure to bolster his popularity with a large portion of his political base.

In 2011, he successfully championed the legalization of gay marriage in New York. And a year ago, in the aftermath of the mass school shooting in Newtown, Conn., Cuomo pushed through legislation giving New York some of the nation’s toughest gun-control laws. He has also pushed, unsuccessfully so far, to strengthen abortion rights in state law.

The governor’s action also comes as advocates for changing drug laws have stepped up criticism of New York City’s stop-and-frisk police tactics, as well as the city’s stringent enforcement of marijuana laws, which resulted in nearly 450,000 misdemeanor charges between 2002 and 2012, according to the Drug Policy Alliance, which advocates more liberal drug laws.

During that same period, medical marijuana became increasingly widespread outside New York, with some 20 states and the District of Columbia now allowing its use.

Cuomo voiced support for changing drug laws as recently as the 2013 legislative session, when he backed an initiative to decriminalize so-called open view possession of 15 grams or less. And though he said he remained opposed to medical marijuana, he indicated as late as April that he was keeping an open mind.

His about-face, according to a person briefed on the governor’s views but not authorized to speak on the record, was rooted in his belief that the program he has drawn up can help those in need, while limiting the potential for abuse. Given Cuomo’s long-held concerns, this person said, the governor insisted that it be a test program so he can monitor its impact.

But Cuomo is also up for election this year, and polls have shown overwhelming support for medical marijuana in New York: Eighty-two percent of New York voters approved of the idea in a survey by Siena College last May.

Still, Cuomo’s plan is sure to turn heads in Albany. Medical marijuana bills have passed the Assembly four times, only to stall in the Senate.

Cuomo has decided to bypass the Legislature altogether.

In taking the matter into his own hands, the governor is relying on a provision in the public health law known as the Antonio G. Olivieri Controlled Substance Therapeutic Research Program. It allows for the use of controlled substances for “cancer patients, glaucoma patients and patients afflicted with other diseases as such diseases are approved by the commissioner.”

Olivieri was a New York City councilman and state assemblyman who died in 1980 at age 39. Suffering from a brain tumor, he used marijuana to overcome some of the discomfort of chemotherapy, and until his death he lobbied for state legislation to legalize its medical use.

The provision, while unfamiliar to most people, had been hiding in plain sight since 1980.

But with Cuomo still publicly opposed to medical marijuana, state lawmakers had been pressing ahead with new legislation that would go beyond the Olivieri statute.

Richard N. Gottfried, a Manhattan Democrat who leads the assembly’s health committee, has held two public hearings on medical marijuana in recent weeks, hoping to build support for a bill under which health care professionals licensed to prescribe controlled substances could certify patient need.

Gottfried said the state’s historical recalcitrance on marijuana was surprising.

“New York is progressive on a great many issues, but not everything,” he said.