A subset of essential cellular proteins requires the assistance of chaperonins (in Escherichia coli, GroEL and GroES), double-ring complexes in which the two rings act alternately to bind, encapsulate and fold a wide range of nascent or stress-denatured proteins. This process starts by the trapping of a substrate protein on hydrophobic surfaces in the central cavity of a GroEL ring. Then, binding of ATP and co-chaperonin GroES to that ring ejects the non-native protein from its binding sites, through forced unfolding or other major conformational changes, and encloses it in a hydrophilic chamber for folding. ATP hydrolysis and subsequent ATP binding to the opposite ring trigger dissociation of the chamber and release of the substrate protein. The bacteriophage T4 requires its own version of GroES, gp31, which forms a taller folding chamber, to fold the major viral capsid protein gp23 (refs 16-20). Polypeptides are known to fold inside the chaperonin complex, but the conformation of an encapsulated protein has not previously been visualized. Here we present structures of gp23-chaperonin complexes, showing both the initial captured state and the final, close-to-native state with gp23 encapsulated in the folding chamber. Although the chamber is expanded, it is still barely large enough to contain the elongated gp23 monomer, explaining why the GroEL-GroES complex is not able to fold gp23 and showing how the chaperonin structure distorts to enclose a large, physiological substrate protein.