Type Ia supernovae have been used empirically as `standard candles’ to demonstrate the acceleration of the expansion of the Universe even though fundamental details, such as the nature of their progenitor systems and how the stars explode, remain a mystery. There is consensus that a white dwarf star explodes after accreting matter in a binary system, but the secondary body could be anything from a main-sequence star to a red giant, or even another white dwarf. This uncertainty stems from the fact that no recent type Ia supernova has been discovered close enough to Earth to detect the stars before explosion. Here we report early observations of supernova SN 2011fe in the galaxy M101 at a distance from Earth of 6.4 megaparsecs. We find that the exploding star was probably a carbon-oxygen white dwarf, and from the lack of an early shock we conclude that the companion was probably a main-sequence star. Early spectroscopy shows high-velocity oxygen that slows rapidly, on a timescale of hours, and extensive mixing of newly synthesized intermediate- mass elements in the outermost layers of the supernova. A companion paper uses pre-explosion images to rule out luminous red giants and most helium stars as companions to the progenitor.