Ruling means that potentially thousands of permits the state issued over the past several years were improperly reviewed.