Atrazine (ATZ), a widely used triazine herbicide, has been shown to disrupt reproductive development in organisms. Melatonin (MLT) is a natural hormone and has been shown to have strong antioxidant properties. Due to its lipophilicity, it can cross biological barriers freely and act on germ cells directly. However, the mechanism through which melatonin affects atrazine-induced damage to male sperm cells remains unclear. This study aimed to investigate the effects of ATZ on spermatocyte development and to elucidate MLT's role in preventing ATZ-induced spermatogenesis failure. Pubertal mice were randomly divided into four groups: blank control group (Con), 5 mg/kg melatonin group (MLT), 170 mg/kg atrazine group (ATZ), and ATZ + MLT group. GC-1 cell culture was employed to access the in vitro effects of MLT and ATZ on spermatogonia. The results indicate that atrazine affected protein and metabolite composition, and reduced sperm viability, sperm motility (VAP, VSL and VCL) and levels of proteins related to spermatogenesis function in the mice testis. Melatonin alleviated the development of cellular DNA damage and necroptosis caused by atrazine both in vivo and in vitro. Moreover, we proposed that it was GC-1 cells developing necroptosis, but not other cell types in the testis. In conclusion, this study suggests that atrazine disrupts the development process, causing DNA damage in spermatozoa during spermatogenesis. Additionally, ATZ-induced necroptosis specifically targets spermatogenic cells. Notably, melatonin alleviates atrazine-induced necroptosis and DNA damage in spermatogenic cells. This study provides new insights into potential therapeutic strategies for atrazine-induced male infertility.