In this study, we explore the impact of the establishment of environmental courts, an environmental justice system, on the cost of equity capital. Based on a quasi-natural experiment of establishing environmental courts in China, we find that they have a deterrent effect and reduce the cost of equity capital for heavily polluting firms in localities. We also find that a low proportion of managerial ownership, a low level of analyst attention, and high environmental uncertainty induce this deterrent effect. Furthermore, mechanism tests indicate that environmental courts enhance corporate environmental engagement and corporate ESG ratings, increase long-term institutional investor ownership, and reduce urban environmental violations to achieve a deterrent effect. The findings are more pronounced for the trial court sample, firms in cities with lower public participation in environmental protection, and firms with lower environmental information transparency. We also suggest the impacts and underlying mechanisms of the environmental justice system on the equity capital market, which is conducive to long-term planning by firm managers.