New Zealand parliament on Tuesday passed legislation to legalize medical marijuana through its third and final vote.

The legislation will now go through Royal Assent (a formality for a measure to become law), and will take effect the following day. Rules to regulate licensing and quality standards will be established in the next 12 months, reports the Marijuana Business Daily. The bill also removes cannabidiol as a controlled drug, instead making it a prescription medicine.

The initial bill would have allowed for cannabis use by anyone with a diagnosed terminal illness – which would have greatly limited its application. That was broadened in the final months of debate to include any patient requiring palliation.

Health Minister Dr. David Clark said that will open the door to medical marijuana use for approximately 25,000 New Zealanders.The expansion allows patients to “procure, possess, consume, smoke or otherwise use any plant or plant material of the genus cannabis or any cannabis preparation,” according to the Misuse of Drugs (Medicinal Cannabis) Amendment Bill.

A certificate from a medical practitioner or nurse practitioner will be required.

According to the law, the regulations “must not require that the variety of cannabis contained in the product was brought into New Zealand with authorization, if the variety is established in New Zealand at the time the product is manufactured or produced.”

In other words, medical cannabis strains currently used in New Zealand illicitly will have a path to be brought into the legal market.

“People nearing the end of their lives should not have to worry about being arrested or imprisoned for trying to manage their pain,” Clark said. “So as a compassionate measure we are also creating a statutory defense for people eligible to receive palliation so that they can use illicit cannabis without fear of prosecution.

“These medicinal products will be available on prescription. This will be particularly welcome as another option for people who live with chronic pain.”

In 2019, the Ministry of Health plans to consult the public on the quality standards, licensing system and regulations required as part of New Zealand’s medical cannabis scheme.