Mastitis, caused by a variety of pathogenic microorganisms, seriously threatens the safety and economic benefits of the dairy industry. Vitexin, a flavone glucoside found in many plant species, has been widely reported to have antioxidant, anti-inflammatory, antiviral, anticancer, neuroprotective, and cardioprotective effects. However, few studies have explored the effect of vitexin on mastitis. This study is aimed at exploring whether the antioxidant and anti-inflammatory functions of vitexin can improve Staphylococcus aureus-induced mastitis and its possible molecular mechanism. The expression profiles of S. aureus-infected bovine mammary epithelial cells and gland tissues from the GEO data set (GSE94056 and GSE139612) were analyzed and found that DEGs were mainly involved in immune signaling pathways, apoptosis, and ER stress through GO and KEGG enrichment. Vitexin blocked the production of ROS and increased the activity of antioxidant enzymes (SOD, GSH-PX, and CAT) via activation of PPARγ in vivo and in vitro. In addition, vitexin reduced the production of inflammatory cytokines (TNF-α, IL-1β, and IL-6) and inhibited apoptosis in MAC-T cells and mouse mammary tissues infected with Staphylococcus aureus. Moreover, vitexin decreased the expression of PDI, Ero1-Lα, p-IRE1α, PERK, p-eIF2α, and CHOP protein but increased BiP in both mammary gland cells and tissues challenged by S. aureus. Western blot results also found that the phosphorylation levels of JNK, ERK, p38, and p65 were reduced in vitexin-treated tissues and cells. Vitexin inhibited the production of ROS through promoting PPARγ, increased the activity of antioxidant enzymes, and reduced inflammatory cytokines and apoptosis by alleviating ER stress and inactivation MAPKs and NF-κB signaling pathway. Vitexin maybe have great potential to be a preventive and therapeutic agent for mastitis.