Types 1 and P pili are prototypical bacterial cell-surface appendages playing essential roles in mediating adhesion of bacteria to the urinary tract. These pili, assembled by the chaperone-usher pathway, are polymers of pilus subunits assembling into two parts: a thin, short tip fibrillum at the top, mounted on a long pilus rod. The rod adopts a helical quaternary structure and is thought to play essential roles: its formation may drive pilus extrusion by preventing backsliding of the nascent growing pilus within the secretion pore; the rod also has striking spring-like properties, being able to uncoil and recoil depending on the intensity of shear forces generated by urine flow. Here, we present an atomic model of the P pilus generated from a 3.8 Å resolution cryo-electron microscopy reconstruction. This structure provides the molecular basis for the rod's remarkable mechanical properties and illuminates its role in pilus secretion.