I'm not a lawyer, but cities and towns can pass their own laws with the permission of the State, but only with permission isn't exactly true.
I'm not aware of any local government asking permission for passing a law of any higher government.
Tangent: what's the ordering, and does it vary with state? In NY we have county govt, town, city / village.). My understanding is that each level down can be more restrictive, but not less so, than a level above. That is, NY allows alcohol sales, but not cocaine sales. A local town can make selling alcohol illegal in their town (called a 'dry town'), banning selling in stores and banning bars. But they can't make it legal to sell cocaine.
Of course, what's less clear to me is if County govt overrules City govt, or if they are also orthogonal. Also, apparently, states can choose whether to enforce federal laws apparently - see recent marijuana news. I suppose that cities can choose whether to enforce state laws also? It's quite confusing, and I live here.