Los Angeles’ ban on new medical marijuana dispensaries is invalid, a Superior Court judge said Monday in a decision that undermines the city’s 4-month-old drive to shut down hundreds of the stores.

The judge issued an injunction banning enforcement of the moratorium against Green Oasis, a dispensary in Playa Vista that had challenged the ban. But city officials acknowledged the ruling would effectively block current efforts to enforce the ban against other dispensaries.

The decision came on the day the Obama administration issued guidelines that limit federal prosecution of medical marijuana users and dispensaries. A Justice Department memo makes official a policy change that the president adopted earlier this year -- one that inadvertently contributed to the city’s dizzying dispensary boom.

Those actions cheered supporters of medical marijuana, but Los Angeles officials insisted they were committed to closing down and prosecuting dispensaries. The city attorney and the district attorney maintain that most are selling marijuana for profit in violation of state law.

Dist. Atty. Steve Cooley did not back off that position Monday. “A collaboration of numerous agencies, including federal, state and local police agencies, county and city prosecutors, will combat the proliferation of illegal medical marijuana dispensaries in Los Angeles City and County,” he said.

Several City Council members said the ruling will force them to take quick action to pass an ordinance that could lead to law enforcement raids to close dispensaries that opened after the moratorium was adopted in August 2007.

“Anyone who doesn’t comply is going to be taken down,” warned Councilman Dennis Zine, who initiated the council’s consideration of dispensaries more than four years ago. “Once we take a few down and some publicity comes about, those who are in it for the cash business will say it’s too hot, let’s get out of it.”

David Berger, a special assistant to City Atty. Carmen Trutanich, said a new draft of the ordinance would be submitted to the council today.

Berger also acknowledged the moratorium had been extended improperly and said the city would not appeal.

At Monday’s hearing, Judge James C. Chalfant said he had hoped to learn that the council had adopted a permanent ordinance. “I thought you would come in and tell me this was all moot,” he said.

“This is the city of Los Angeles,” replied Assistant City Atty. Jeri Burge. “Sometimes it goes slowly.”

City Councilman Greig Smith, who heads the Public Safety Committee, said he may send the proposed ordinance to the full council for emergency consideration so it could be approved immediately. The measure has been debated for more than two years in the planning committee and was recently sent to Smith’s panel.

Chalfant’s decision dismayed community activists, who have pleaded with the council to crack down on dispensaries that have opened up throughout the city but are heavily concentrated in some neighborhoods.

“It looks like not only will the ones that are open continue to operate, but there will be more that open also, and the whole business will start expanding exponentially, I think, knowing that L.A. city is completely inept at handling control on these,” said Michael Larsen, the public safety director for the Eagle Rock Neighborhood Council.

In his decision, Chalfant concluded that the city had failed to follow state requirements when it extended its initial moratorium. “The city cannot rely on an expired ordinance,” he said.

Burge warned, “You’re going to open the floodgates.”

In a court filing, the city said an injunction would cause “grave irreparable harm.”

“This lawsuit is not just about one ‘bad apple.’ It is about illegally dealing marijuana,” the city argued. “Hundreds of unlawful marijuana stores have cropped up throughout the city and will likely attempt to bootstrap their illegal operation on the outcome of this action.”

Chalfant dismissed that claim, saying the city had other means to shut down dispensaries. “That’s so clearly in your hands,” he said, noting that some cities have adopted outright bans.

Robert A. Kahn, Green Oasis’ attorney, said the city was trying to punish dispensaries for a situation that arose from the council’s own failures.

“They clearly blew it, they blew the way they are supposed to be handling these ordinances,” he said. “The Compassionate Use Act was passed in 1996. What have they been doing for the last 13 years?”

The council started to look at the issue in 2005, when Zine asked the Police Department for a report on dispensaries. The moratorium took effect Sept. 14, 2007, and allowed 186 dispensaries to remain in business. The City Council extended the moratorium to last for two years. It adopted a second moratorium to last through mid-March.

In court Monday, the city argued that the council did not need to comply with a state law that requires certain steps to extend a zoning moratorium. Burge argued that it was a public safety, rather than a zoning, moratorium. Zoning moratoriums cannot be extended beyond 24 months. Chalfant quickly dispensed with that theory.

“Although there may be overtones of public safety,” he said, “this is a zoning issue.”

Besides failing to adhere to state law when it extended the ban, the city also failed to enforce it.

Hundreds of dispensaries filed applications for hardship exemptions from the moratorium, and many opened without permission. The City Council began to deny those requests this summer, which allowed city officials to file civil or criminal charges. None have been filed, however, and Berger said the city attorney’s office now will not file charges until there is a permanent ordinance.

Green Oasis, which is on Jefferson Boulevard just west of the 405 Freeway, sought a hardship exemption in April and opened in May, without waiting for the City Council to act on the request. In July, the City Council denied the exemption. The city attorney’s office notified Green Oasis that its operators faced civil and criminal violations, including a $1,000 fine and six months in jail. The dispensary sued last month.

Dan Lutz, a co-owner of Green Oasis, said he was relieved by the decision but wished he was not in an adversarial stance with the city. “A lot of the collectives out there are wanting to do a good job and provide a valuable service for the community, and we’re actually surprised that we’re in this position in L.A.,” he said.

Lutz’s dispensary was in the city’s sights even before he filed suit.

An undercover narcotics officer visited at least twice, according to a declaration Officer Brent Olsen filed with the court. On Sept. 2, he said he handed over his identification and doctor’s recommendation and filled out a form. Buzzed into an interior room, he said he was told there were 60 strains available. He paid $58 for one-eighth of an ounce of marijuana. On Sept. 10, he paid $55 for another eighth.

“It is my opinion that the dispensary is being used to sell marijuana,” Olsen said in the declaration. He noted that he had not participated as a member of a collective or in any collective cultivation.

Lutz could also be in jeopardy on other grounds. The city attorney’s office says the dispensary failed to obtain a building permit or a certificate of occupancy.

“They could come after us for many things,” Lutz said. “What can we do?”

john.hoeffel@latimes.com