The law will enter into force after approval of the parliament and after it is published in the official bulletin.
The same draft law provides for the setting up of a national agency in charge of buying the plant from farmers and selling it to pharmaceutical firms, Moroccan media reported.
The same text limits the plantation of cannabis to six regions only in northern Morocco and bans using the substance for recreational purposes.
The text comes after the UN dropped cannabis from the list of most dangerous drugs and acknowledged its medical benefits.
The UN move came after a recommendation from the World Health Organization to remove cannabis and cannabis resin from its Schedule IV classification under the 1961 Single Convention on Narcotic Drugs.
Many countries look to global conventions for guidance, and United Nations recognition is a symbolic win for advocates of drug policy change.
Legalizing the use of cannabis in Morocco has been a hot issue, particularly after some MPs campaigned for allowing cannabis to be used for medical purposes.
Some 400,000 Moroccan farmers are involved in the plantation of cannabis over 73,000 hectares.