LOS ANGELES  A temporary moratorium on establishing new medical marijuana dispensaries here was ruled invalid by a county judge on Monday, complicating the city’s efforts to crack down on cannabis clubs.

The judge, James C. Chalfant of Superior Court, granted an injunction on behalf of Westside Green Oasis, a medical marijuana shop, which had challenged a Los Angeles ordinance that put a moratorium on new dispensaries in 2007. The club, which opened after the City Council halted the establishment of new shops, said the moratorium violated the state’s Compassionate Use Act.

The moratorium was intended as a stopgap measure to give city officials time to establish permanent regulations. State law lets a city impose moratoriums of up to two years while it establishes ordinances governing medical marijuana.

The Los Angeles ban in 2007 permitted only 186 marijuana dispensaries. Two years later, hundreds more medical marijuana shops have opened, and the City Council has yet to pass a permanent ordinance governing medical cannabis.