We examine the impact of environmental credit regulation on the environmental investment of heavily polluting firms. The empirical results show that the policy significantly increases environmental investment by heavily polluting firms, leveraging mechanisms such as media attention, investor attention, executives' green cognition, and financial risk. Moreover, the policy effects are more pronounced in regions with a high proportion of institutional investor ownership or low levels of digital financial development. The policy also significantly reduces carbon emissions of heavily polluting firms and enhances their fulfillment of social responsibility.