Veterans, some of whom have been at the forefront of the medical marijuana movement, praised the department’s decision. They say cannabis helps soothe physical and psychological pain and can alleviate the side effects of some treatments.

“By creating a directive on medical marijuana, the V.A. ensures that throughout its vast hospital network, it will be well understood that legal medical marijuana use will not be the basis for the denial of services,” Mr. Krawitz said.

Although the Obama administration has not embraced medical marijuana, last October, in a policy shift, the Justice Department announced that it would not prosecute people who used or distributed it in states where it was legal.

Laura Sweeney, a spokeswoman for the Justice Department, would not comment spefically on the veterans department policy. “What we have said in the past, and what we have said for a while, is that we are going to focus our federal resources on large scale drug traffickers,” she said. “We are not going to focus on individual cancer patients or something of the like.”

Many clinicians already prescribe pain medication to veterans who use medical marijuana, as there was no rule explicitly prohibiting them from doing so, despite the federal marijuana laws.

Advocates of medical marijuana use say that in the past, the patchwork of veterans hospitals and clinics around the country were sometimes unclear how to deal with veterans who needed pain medications and were legally using medical marijuana. The department’s emphasis on keeping patients off illegal drugs and from abusing their medication “gave many practitioners the feeling that they are supposed to police marijuana out of the system,” Mr. Krawitz said.

“Many medical-marijuana-using veterans have just abandoned the V.A. hospital system completely for this reason,” he said, “and others that stay in the system feel that they are not able to trust that their doctor will be working in their best interests.”