Dairy farming is the most important economic activity in animal husbandry. Mastitis is the most common disease in dairy cattle and has a significant impact on milk quality and yield. The natural extract allicin, which is the main active ingredient of the sulfur-containing organic compounds in garlic, has anti-inflammatory, anticancer, antioxidant, and antibacterial properties; however, the specific mechanism underlying its effect on mastitis in dairy cows needs to be determined. Therefore, in this study, whether allicin can reduce lipopolysaccharide (LPS)-induced inflammation in the mammary epithelium of dairy cows was investigated. A cellular model of mammary inflammation was established by pretreating bovine mammary epithelial cells (MAC-T) with 10 µg/mL LPS, and the cultures were then treated with varying concentrations of allicin (0, 1, 2.5, 5, and 7.5 µM) added to the culture medium. MAC-T cells were examined using RT–qPCR and Western blotting to determine the effect of allicin. Subsequently, the level of phosphorylated nuclear factor kappa-B (NF-κB) was measured to further explore the mechanism underlying the effect of allicin on bovine mammary epithelial cell inflammation. Treatment with 2.5 µM allicin considerably decreased the LPS-induced increase in the levels of the inflammatory cytokines interleukin-1β (IL-1β), interleukin-6 (IL-6), interleukin-8 (IL-8), and tumor necrosis factor-α (TNF-α) and inhibited activation of the NOD-like receptor protein 3 (NLRP3) inflammasome in cow mammary epithelial cells. Further research revealed that allicin also inhibited the phosphorylation of inhibitors of nuclear factor kappa-B-α (IκB-α) and NF-κB p65. In mice, LPS-induced mastitis was also ameliorated by allicin. Therefore, we hypothesize that allicin alleviated LPS-induced inflammation in the mammary epithelial cells of cows probably by affecting the TLR4/NF-κB signaling pathway. Allicin will likely become an alternative to antibiotics for the treatment of mastitis in cows.