Non-suicidal self-injury (NSSI) is a widespread behavior among adolescents that severely damages their physical and mental well-being. Research indicates that deviant peer affiliation serves as an indicator of adolescents’ vulnerability to NSSI. However, insufficient research has been conducted to explore the mechanisms underlying how and when deviant peer affiliation is associated with adolescent NSSI. Therefore, this study employed a longitudinal design encompassing three phases to examine the serial mediation effects of basic psychological needs satisfaction (BPNS) and depression on the relationship between deviant peer affiliation and NSSI among adolescents in China, while also considering the moderating role of emotion dysregulation in this serial mediation model (N = 886, Mage at T1 = 10.17 years, SD = 0.73 years). The results revealed that the linkage between T1 deviant peer affiliation and T3 NSSI was serially mediated by T2 BPNS and T2 depression. Additionally, a moderating effect of T2 emotion dysregulation was revealed. Specifically, among adolescents with a high level of emotion dysregulation, the serial mediation effect of BPNS and depression on the correlation between deviant peer affiliation and NSSI was stronger. This study enhances our understanding of the mechanisms linking deviant peer affiliation and NSSI among early adolescents and offers a new perspective for preventing and intervening in NSSI.