Mitochondria, chloroplasts, and Gram-negative bacteria are encased in a double layer of membranes. The outer membrane contains proteins with a β-barrel structure1,2. β-barrels are sheets of β-strands wrapped into a cylinder with the first strand hydrogen-bonded to the last strand. Conserved multi-subunit molecular machines fold and insert these proteins into the outer membrane3–5. One subunit of the machines is itself a β-barrel protein that plays a central role in folding other β-barrels. In Gram-negative bacteria, the β-barrel assembly machine (Bam) consists of the β-barrel protein BamA and four lipoproteins5–8. To understand how the Bam complex accelerates folding without using exogenous energy (e.g., ATP)9, we trapped folding intermediates on the machine. We report here the structure of the Bam complex folding BamA itself. The BamA catalyst (BamAM, for BamAmachine) forms an asymmetric hybrid β-barrel with the BamA substrate (BamAS). The N-terminal edge of BamAM has an antiparallel hydrogen-bonded interface with the C-terminal edge of BamAS, consistent with previous crosslinking studies10–12; the other edges of BamAM and BamAS are close to each other but curl inward and do not pair. Six hydrogen bonds in a membrane environment make the interface between the two proteins very stable. This stability allows folding but creates a high kinetic barrier to substrate release once folding has finished. Features at each end of the substrate overcome the barrier and promote release by stepwise exchange of hydrogen bonds. This mechanism of substrate-assisted product release explains how the Bam complex can stably associate with the substrate during folding and then turn over rapidly when folding is complete.