Uromodulin is the most abundant protein in human urine, and it forms filaments that antagonize the adhesion of uropathogens; however, the filament structure and mechanism of protection remain poorly understood. We used cryo–electron tomography to show that the uromodulin filament consists of a zigzag-shaped backbone with laterally protruding arms. N-glycosylation mapping and biophysical assays revealed that uromodulin acts as a multivalent ligand for the bacterial type 1 pilus adhesin, presenting specific epitopes on the regularly spaced arms. Imaging of uromodulin-uropathogen interactions in vitro and in patient urine showed that uromodulin filaments associate with uropathogens and mediate bacterial aggregation, which likely prevents adhesion and allows clearance by micturition. These results provide a framework for understanding uromodulin in urinary tract infections and in its more enigmatic roles in physiology and disease.