This is a really interesting question, because it delves into the grey area of federal law, and involves both illegal substances, and gun laws.
Marijuana is federally illegal as a Schedule 1 controlled substance. Furthermore, it is illegal for to possess a firearm if you use a controlled substance. Therefore technically the answer is clear that the two together are illegal. Indeed the Bureau of Alcohol, Tobacco, Firearms and Explosives recently explained, "There are no exceptions in federal law for marijuana purportedly used for medicinal purposes, even if such use is sanctioned by state law."
Additionally the 9th U.S. Circuit Court of Appeals recently ruled that it was not illegal for an arms dealer to refuse service to someone with an active marijuana card.
It’s important to note that in California at least, there is no requirement to report your doctor’s medical marijuana recommendation to the state, or apply for a state issued ID card. Moreover, your medical information is protected by HIPAA laws, and at least if you use a reputable service like HelloMD, is not available to anyone other than you and your doctor. Therefore, unless you decide to disclose that you have a medical marijuana recommendation to a gun dealer, there is no likelihood that this should be an impediment to your gun purchase or ownership. All medical cannabis users are already flouting federal laws on controlled substances, so I personally don’t see this as different.
There are many conflicts between state and federal law. Normally, federal law trumps state law. So you may be asking yourself “how can patients acquire their marijuana legally?” Currently, the federal government has taken a hands off approach to medical marijuana and has allowed states to govern themselves in this arena. However, federally, marijuana whether it be medicinal or recreational is still a controlled substance and therefore illegal. Therefore under federal law, a person who has a medical marijuana card may not possess a firearm due to the fact that they are using a controlled substance. The Department of Justice has stated that it will not prosecute a person that is in full compliance with state medical marijuana laws and therefore, federal prosecution is unlikely in this scenario.
Hi there! As a gun owner, you probably already know CA laws for firearms are stricter than in most states. There are, for example, limitations on rate of fire and magazine size. But a restriction under federal law is in effect nationwide. The ATF has banned guns for sale to medical cannabis card holders. However, recreational marijuana consumers are not being penalized, which is confusing! Here's an article on the subject by LA Weekly.