Cadmium (Cd) is a widely used heavy metal and has recently been recognized as a possible source of human toxicity due to its ability to accumulate in organs. Accumulation of heavy metals has several adverse effects, including inducing inflammation, in multiple organs, including the testis. However, how Cd ions are sensed by host cells and how tissue inflammation eventually occurs remains unclear. Here, we show that Cd activates the AIM2 inflammasome by mediating genomic DNA release into the cytoplasm after DNA damage via oxidative stress to trigger IL-1 beta secretion and pyroptosis. Specifically, the toxicity effects induced by Cd in cells were prevented by melatonin, which served as an antagonist of oxidative stress. Accordingly, in a mouse model, Cd-induced inflammation in the testis and consequential male reproductive dysfunction were effectively reversed by melatonin. Thus, our results suggest a function of AIM2 in Cd-mediated testis inflammation and identify AIM2 as a major pattern recognition receptor in response to heavy metal Cd ions.