BOSTON The office of Massachusetts Attorney General Martha Coakley has issued a decision that towns and cities cannot enact total bans on medical marijuana dispensaries within their borders.

The decision (PDF), released in response to a Wakefield bylaw banning dispensaries in the town, says such a ban would “frustrate the purpose” of the medical marijuana law voters passed through Question 3 on the November 2012 ballot.

The decision, written by Assistant Attorney General Margaret Hurley, director of the Municipal Law Unit, says the law’s legislative purpose “could not be served if a municipality could prohibit treatment centers within its borders, for if one municipality could do so, presumably all could do so.”

Municipalities are, however, allowed to adopt zoning bylaws to regulate dispensaries, according to Hurley.

In a separate decision in response to a bylaw passed by the town of Burlington, Hurley says towns can adopt temporary moratoriums on dispensaries in order to have time to plan properly.

Ruth Clay, the health director for Wakefield, Reading and Melrose — all of which recently approved dispensary bans — said she’s “disappointed” with the decision but understands the reasoning behind it.

“The towns will look at the variety of options that include potentially having a moratorium… or having restrictions,” Clay said.

In an earlier WBUR interview on Monday, Clay said although she and other local officials aren’t “morally opposed” to medical marijuana, dispensaries wouldn’t be “in keeping with the vision” for the towns. They have a strong focus on substance abuse prevention through the use of federal Drug Free Communities grants, she said, and are concerned youth marijuana use will increase if dispensaries open there.

Wednesday’s decision rejects the idea of any municipality banning dispensaries, but the attorney general only has statutory authority over town bylaws, not ordinances passed by cities.