Pilin assembly into type IV pili is required for virulence by bacterial pathogens that cause diseases such as cholera, pneumonia, gonorrhea, and meningitis. Crystal structures of soluble, N-terminally truncated pilin from Vibrio cholera toxin-coregulated pilus (TCP) and full-length PAK pilin from Pseudomonas aeruginosa reveal a novel TCP fold, yet a shared architecture for the type IV pilins. In each pilin subunit a conserved, extended, N-terminal alpha helix wrapped by beta strands anchors the structurally variable globular head. Inside the assembled pilus, characterized by cryo-electron microscopy and crystallography, the extended hydrophobic alpha helices make multisubunit contacts to provide mechanical strength and flexibility. Outside, distinct interactions of adaptable heads contribute surface variation for specificity of pilus function in antigenicity, motility, adhesion, and colony formation.