The diffuse extragalactic background light consists of the sum of the starlight emitted by galaxies through the history of the Universe, and it could also have an important contribution from the 'first stars', which may have formed before galaxy formation began. Direct measurements are difficult and not yet conclusive, owing to the large uncertainties caused by the bright foreground emission associated with zodiacal light1. An alternative approach2-5is to study the absorption features imprinted on the γ-ray spectra of distant extragalactic objects by interactions of those photons with the background light photons6. Here we report the discovery of γ-ray emission from the blazars7H 23562309 and 1ES 1101-232, at redshiftsz = 0.165 andz = 0.186, respectively. Their unexpectedly hard spectra provide an upper limit on the background light at optical/near-infrared wavelengths that appears to be very close to the lower limit given by the integrated light of resolved galaxies8. The background flux at these wavelengths accordingly seems to be strongly dominated by the direct starlight from galaxies, thus excluding a large contribution from other sources-in particular from the first stars formed9. This result also indicates that intergalactic space is more transparent to γ-rays than previously thought.