BOSTON — Tens of thousands of Massachusetts residents could be at risk of losing their jobs if they use marijuana for medical relief, as government agencies work to balance the new state medical marijuana law with federal law, which says the drug is illegal under all circumstances.

One potential scenario: A doctor who becomes a medical marijuana patient would be at “significant risk” of violating his or her license to practice medicine, according to Bill Ryder, legislative and regulatory counsel for the Massachusetts Medical Society.

Ryder says the main problem for doctors is a question on the state license application that asks, “Do you use an illegal drug?” The state Board of Registration in Medicine, which reviews physician licenses and applications, may still be bound to interpret “illegal drug” according to federal law.