Plants and animals recognize conserved flagellin fragments as a signature of bacterial invasion. These immunogenic elicitor peptides are embedded in the flagellin polymer and require hydrolytic release before they can activate cell surface receptors. Although much of flagellin signaling is understood, little is known about the release of immunogenic fragments. We discovered that plant-secreted b-galactosidase 1 (BGAL1) of Nicotiana benthamiana promotes hydrolytic elicitor release and acts in immunity against pathogenic Pseudomonas syringae strains only when they carry a terminal modified viosamine (mVio) in the flagellin O-glycan. In counter defense, P. syringae pathovars evade host immunity by using BGAL1-resistant O-glycans or by producing a BGAL1 inhibitor. Polymorphic glycans on flagella are common to plant and animal pathogenic bacteria and represent an important determinant of host immunity to bacterial pathogens.