The supercoiling of bacterial and archaeal flagellar filaments is required for motility. Archaeal flagellar filaments have no homology to their bacterial counterparts and are instead homologs of bacterial type IV pili. How these prokaryotic flagellar filaments, each composed of thousands of copies of identical subunits, can form stable supercoils under torsional stress is a fascinating puzzle for which structural insights have been elusive. Advances in cryoelectron microscopy (cryo-EM) make it now possible to directly visualize the basis for supercoiling, and here, we show the atomic structures of supercoiled bacterial and archaeal flagellar filaments. For the bacterial flagellar filament, we identify 11 distinct protofilament conformations with three broad classes of inter-protomer interface. For the archaeal flagellar filament, 10 protofilaments form a supercoil geometry supported by 10 distinct conformations, with one inter-protomer discontinuity creating a seam inside of the curve. Our results suggest that convergent evolution has yielded stable superhelical geometries that enable microbial locomotion.