Melatonin, a secretory product of the pineal gland, has been reported to have antioxidant and anti-inflammatory effects. However, the protective effects of melatonin on lipopolysaccharide (LPS)-induced mastitis have not been reported. The purpose of this study was to investigate the anti-inflammatory effects and the underlying mechanisms of melatonin on LPS-induced mastitis both in vivo and in vitro. In vivo, our results showed that melatonin attenuated LPS-induced mammary histopathologic changes and myeloperoxidase (MPO) activity. Melatonin also inhibited LPS-induced inflammatory cytokines tumor necrosis factor-α (TNF-α), interleukin-1β (IL-1β) and interleukin-6 (IL-6) production in mammary tissues. In vitro, melatonin was found to inhibit LPS-induced TNF-α and IL-6 production in mouse mammary epithelial cells. Melatonin also suppressed LPS-induced Toll-like receptor 4 (TLR4) expression and nuclear factor-kappaB (NF-κB) activation in a dose-dependent manner. In addition, melatonin was found to up-regulate the expression of PPAR-γ. Inhibition of PPAR-γ by GW9662 reduced the anti-inflammatory effects of melatonin. In conclusion, we found that melatonin, for the first time, had protective effects on LPS-induced mastitis in mice. The anti-inflammatory mechanism of melatonin was through activating PPAR-γ which subsequently inhibited LPS-induced inflammatory responses.