This previous answer by u/hillsonghoods may interest you:
I can't speak for the rest of the world, but here's how it happened in Mexico:
Cannabis gets introduced to Mexico as a source of industrial hemp. At the time, hemp was used heavily for sails, rope, and other accessories for Spanish ships, so growing it in Mexico and other colonies would become a relatively common practice. At first, this hemp production was the project of a conquistador named Pedro Quadrado, but in 1545 the Spanish crown began to instruct their viceroys to grow hemp in Mexico.
As hemp production grew in Mexico, cannabis came to be used in indigenous religious practices. The history here (1600s/1700s) gets a little muddy, as for some time the Spanish crown and Catholic Church don't understand that the pipiltzintzintlis the indigenous populations were using and cultivating was the same as the hemp that they were growing. At this point, we start to see some local governments and churches banning the use of cannabis. We also start to see cannabis gaining a reputation as a drug that causes hallucinations and violence.
And where does this reputation come from? In Home Grown, Isaac Campos argues for the idea of the psychoactive riddle: the idea that the effects of a drug are caused by "drug, set, and setting." The exact meaning of those words is very important.
Drug: EXACT composition of the drug ingested. Note that Mexican indigenous medicine typically involves mixtures of plants, not just use of one.
Set: What YOU think the drug will do to you.
Setting: The societal beliefs about what the drug will do.
With these considered, it's possible that the cannabis used by indigenous Mexicans may have caused something like violence or hallucinations.
Also damaging to the reputation of cannabis is its association with indigenous populations, prisoners, and soldiers. Cannabis becomes the chosen vice of prisoners and soldiers mainly due to ease of cultivation. In much of Mexico, cannabis can grow naturally with little upkeep. It's also important to note that the association with soldiers is largely a negative one. At this time, non-officers in the military are mainly viewed as the dregs of society, people who had no other option but to fight. (this part is contested, see below)
In the late 1800s, things begin to come to a head. Newspapers frequently run stories about cannabis inspired violence and delerium. Though relatively few people actually use cannabis in Mexico at this time, these articles become popular. Much of this is likely yellow journalism meant to sell newspapers by generating shock and outrage. The Associated Press allowed these stories to spread quickly across the country and beyond. Campos points out that there's a notable lack of counter-prohibitionist discourse. The popular attitudes towards cannabis are overwhelmingly negative, at least those that are expressed in the media.
After the Mexican Revolution, the newly established government sought to reform land ownership, infrastructure, and morality. There was a prevalent belief that the "Mexican race" had become "infirm" and "degenerated" and would need to make great changes to compete with other nations. One such change was greater regulation of drugs. In a sweeping reform, the Mexican government required permits for doctors to acquire cocaine or opiates. Cannabis, due to its reputation and lack of popular support, becomes entirely prohibited. There's also some talk of banning alcohol, but due to a strong counter-prohibitionist discourse it doesn't go very far.
Sources:
Home Grown by Isaac Campos
Drinking, Homicide, and Rebellion in Colonial Mexican Villages by William B. Taylor
I would like to ask a follow up question. I think I remember reading somewhere that marijuana was banned in part from lobbying by William Randolph Hearst. Wikipedia disputes this, but I was under the impression that he had a stake in the lumber industry as well as media. Can anyone clarify this point?