The light emitted by all galaxies over the history of the Universe produces the extragalactic background light (EBL) at ultraviolet, optical, and infrared wavelengths. The EBL is a source of opacity for $gamma$ rays via photon-photon interactions, le
aving an imprint in the spectra of distant $gamma$-ray sources. We measure this attenuation using {739} active galaxies and one gamma-ray burst detected by the {it Fermi} Large Area Telescope. This allows us to reconstruct the evolution of the EBL and determine the star-formation history of the Universe over 90% of cosmic time. Our star-formation history is consistent with independent measurements from galaxy surveys, peaking at redshift $zsim2$. Upper limits of the EBL at the epoch of re-ionization suggest a turnover in the abundance of faint galaxies at $zsim 6$.