The topics of psychological maltreatment by teachers and children’s cyberbullying perpetration have both attracted increasing research attention. However, clarification of the development and specific psychological mechanisms linking psychological maltreatment by teachers to cyberbullying perpetration by students remains necessary. Thus, this study examined the longitudinal relations between psychological maltreatment by teachers and subsequent cyberbullying perpetration, along with the mediating role of self-esteem and the moderating role of sex. A total of 5563 Chinese elementary school students (56% boys; M age = 9.92 years, SD = 0.74) completed self-report measures on 5 occasions across 2.5 years. Latent growth curve mediation modeling was applied to examine the longitudinal relations among the variables. Results showed that (a) Psychological maltreatment by teachers was positively associated with subsequent cyberbullying perpetration; (b) The developmental trajectory of psychological maltreatment by teachers was indirectly associated with the developmental trajectory of cyberbullying perpetration through the mediating role of self-esteem; (c) Sex moderated the relations among psychological maltreatment by teachers, self-esteem and cyberbullying perpetration among children such that self-esteem mediated the relation between psychological maltreatment by teachers and cyberbullying perpetration for boys but not girls. Implications for the prevention of psychological maltreatment by teachers and cyberbullying perpetration were discussed.