This study examines how environmental legislation affects the intrafirm pay gap. Using China’s New Environmental Protection Law (NEPL), we show that it significantly widens wage inequality inside heavily polluting firms. We provide strong evidence that the effect operates through an executive risk compensation channel, which enlarges the pay gap between top executives and other employees. This effect is more pronounced among firms with poorer environmental performance, firms that do not receive government environmental subsidies, and non-SOEs. We trace the underlying cause to weak internal governance efficiency and agency frictions that prompt firms to expand executive risk compensation. Moreover, corporate social responsibility (CSR) mitigates this impact. Firms with stronger CSR engagement experience a weaker NEPL-induced increase in pay gap. Overall, our findings suggest that internal governance problems can produce unintended distributional consequences when firms are exposed to a regulatory shock.