Bacterial type 4a pili are dynamic surface filaments that promote bacterial adherence, motility, and macromolecular transport. Their genes are highly conserved among enterobacteria and their expression in enterohemorrhagic Escherichia coli (EHEC) promotes adhesion to intestinal epithelia and pro-inflammatory signaling. To define the molecular basis of EHEC pilus assembly, we determined the structure of the periplasmic domain of its major subunit PpdD (PpdDp), a prototype of an enterobacterial pilin subfamily containing two disulfide bonds. The structure of PpdDp, determined by NMR, was then docked into the density envelope of purified EHEC pili obtained by cryoelectron microscopy (cryo-EM). Cryo-EM reconstruction of EHEC pili at ∼8 Å resolution revealed extremely high pilus flexibility correlating with a large extended region of the pilin stem. Systematic mutagenesis combined with functional and interaction analyses identified charged residues essential for pilus assembly. Structural information on exposed regions and interfaces between EHEC pilins is relevant for vaccine and drug discovery.