Background: The poultry industry needs effective antibiotic alternatives to control outbreaks of necrotic enteritis (NE) caused by Clostridium perfringens., Methods: The aim of this study was to investigate the effects of dietary supplementation with Macleaya cordata extract (MCE) on the immune function and gut microbiota of broilers with NE. A total of 288 1-day-old broiler chicks were randomly assigned to a 2 × 2 factorial arrangement with two concentrations of dietary MCE supplementation (0 or 350 mg/kg of diet) and two disease challenge statuses (control or NE)., Results: The results revealed that NE significantly increased the feed conversion rate (FCR), mortality, intestinal lesion score, the levels of IL-1β, IL-17 and IFN-γ/IL-4 in serum and IL-17/IL-10 in the jejunal mucosa, mRNA levels of TLR2, IFN-γ and pIgR in the jejunum, and Clostridium perfringens concentrations in the cecum. NE significantly decreased the body weight (BW), body weight gain (BWG), jejunal villus height, V/C, mRNA level of AMPK-α1 in jejunum, IL-4 level in the jejunal mucosa and lactic acid bacteria abundance in the cecum. MCE significantly increased BW, BWG, jejunal villus height, V/C, mRNA levels of occludin, ZO-1 and AMPK-α1 in the jejunum, the levels of IgA and IgG in serum and IL-10 in the jejunal mucosa and mRNA levels of NF-κB, IL-10 and MHC-II in the jejunum. Additionally, MCE significantly decreased the FCR, mortality, intestinal lesion score, jejunal crypt depth, the levels of IFN-γ and IL-17 in serum and IL-17/IL-10 in the jejunal mucosa, Clostridium perfringens concentrations in the cecum, and mRNA levels of IL-17/IL-10 in the jejunum. Moreover, NE significantly increased the abundance of bacteria that are associated with inflammation, obesity and depression (Alistipes, Barnesiella, Intestinimonas, RF39 and UCG-005) and significantly decreased the abundance of short-chain fatty acid (SCFA)-producing bacteria (Anaerotruncus, Butyricicoccus and Bacteroides) in the cecum. MCE significantly increased the abundance of SCFA-producing bacteria (Streptococcus, Ruminococcus_torques_group and Lachnospiraceae_NK4A136_group) and significantly reduced the abundance of bacteria that are associated with inflammation and obesity (Alistipes, Barnesiella and UCG-010) in the cecum. In the cecum of broilers with NE, the relative abundance of Barnesiella and Alistipes was higher and that of Lachnoclostridium and Shuttleworthia was lower. Interestingly, these trends were reversed by the addition of MCE to the diet. Spearman correlation analysis showed that Barnesiella and Alistipes were associated with enhanced intestinal inflammation and inhibited growth performance, whereas Lachnoclostridium and Shuttleworthia were associated with anti-inflammatory effects., Conclusions: MCE ameliorated the loss of growth performance in broiler chickens with NE, probably by regulating the intestinal barrier, immune function, and gut microbiota., (© 2023. Chinese Association of Animal Science and Veterinary Medicine.)