Many Gram-negative bacteria use type 2 secretion systems (T2SSs) to secrete proteins involved in virulence and adaptation. Transport of folded proteins via T2SS nanomachines requires the assembly of inner membrane-anchored fibres called pseudopili. Although efficient pseudopilus assembly is essential for protein secretion, structure-based functional analyses are required to unravel the mechanistic link between these processes. Here, we report an atomic model for a T2SS pseudopilus from Klebsiella oxytoca, obtained by fitting the NMR structure of its calcium-bound subunit PulG into the ~5-Å-resolution cryo-electron microscopy reconstruction of assembled fibres. This structure reveals the comprehensive network of inter-subunit contacts and unexpected features, including a disordered central region of the PulG helical stem, and highly flexible C-terminal residues on the fibre surface. NMR, mutagenesis and functional analyses highlight the key role of calcium in PulG folding and stability. Fibre disassembly in the absence of calcium provides a basis for pseudopilus length control, essential for protein secretion, and supports the Archimedes screw model for the type 2 secretion mechanism.