Phytopathogens cause various diseases by parasitizing crops, reducing crop yield and resulting in substantial economic losses in agricultural production. A novel type isolated from the perennial herbaceous Peganum harmala L. seeds, β-carboline alkaloids pegaharine A (PA), has become a hot topic in developing plant-originated green pesticides owing to their significant physiological activities. A scalable bioinspired total synthesis of PA is accomplished in the present work. The systematical biological assay study showed that PA exhibited moderate inhibitory activity against nine tested plant pathogenic fungi and showed significant inhibitory activity in vitro against the three tested plant pathogenic bacteria. Most noteworthy is the inhibitory rates of PA on Xanthomonas oryzae pv. oryzae (Xoo), X. oryzae pv. oryzicola (Xoc) and X. axonopodis pv. citri (Xac) of 93.6%, 92.1% and 86.1%, respectively, which are better than the control drug, bismerthiazol (63.4%, 61.2% and 53.7% at 100 μg mL-1 concentration). Furthermore, the EC50 value of PA against Xoo, Xoc and Xac was 52.2, 60.0 and 65.1 μg mL-1 , respectively, superior to 72.9, 64.2 and 70.1 μg mL-1 of the control drug. Moreover, the anti-Xoo mechanistic studies revealed that PA exerted its antibacterial effects by increasing the permeability of the bacterial membrane, reducing the extracellular polysaccharide content and inducing morphological changes in bacterial cells. A novel β-carboline alkaloid, PA, was prepared by biomimetic total synthesis. Its significant antibacterial activity was closely related to the permeation of bacterial cell membranes, which was confirmed by anti-Xoo mechanistic studies. More importantly, the structure could be regarded as a model for developing novel bactericides. © 2023 Society of Chemical Industry.