Observations of molecular hydrogen in quasar host galaxies at high redshifts provide fundamental constraints on galaxy evolution, because it is out of this molecular gas that stars form. Molecular hydrogen is traced by emission from the carbon monoxide molecule, CO; cold H2 itself is generally not observable. Carbon monoxide has been detected in about ten quasar host galaxies with redshifts z > 2; the record-holder is at z = 4.69 (refs 1-3). Here we report CO emission from the quasar SDSS J114816.64 + 525150.3 (refs 5, 6) at z = 6.42. At that redshift, the Universe was only 1/16 of its present age, and the era of cosmic reionization was just ending. The presence of about 2 × 1010M⊙ of H2 in an object at this time demonstrates that molecular gas enriched with heavy elements can be generated rapidly in the youngest galaxies.