In the current economic landscape, businesses are challenged by the dual imperatives of digital transformation and sustainability goals. While digital transformation is often heralded as a catalyst for innovation, its potential negative effects on green innovation remain underexplored. This study fills in this gap by analyzing 1443 listed companies on the Shanghai Stock Exchange main board between 2013 and 2022, focusing on the mechanisms by which digital transformation impacts green innovation and on the moderated role of environmental, social, and governance (ESG) performance. Our findings reveal that digital transformation hinders green innovation by increasing financing constraints. However, good ESG performance mitigates these negative impacts by alleviating financing constraints, thereby fostering green innovation. Our findings hold up against endogeneity tests by applying instrumental variable methods. Notably, the effect of digital transformation and ESG differs significantly between state-owned enterprises (SOEs) and non-state-owned enterprises (non-SOEs). While non-SOEs experience more pronounced challenges, ESG also demonstrates a stronger moderating role, unlike in SOEs, where institutional advantages offset some of these constraints. These findings enhance the understanding of dual transformation challenges, offering practical implications for aligning digital and green strategies in diverse organizational contexts.