A rare class of 'superluminous' supernovae that are about ten or more times more luminous at their peaks than other types of luminous supernova has recently been found at low to intermediate redshifts. A small subset of these events have luminosities that evolve slowly and result in radiated energies of up to about 1051 ergs. Therefore, they are probably examples of 'pair-instability' or 'pulsational pair-instability' supernovae with estimated progenitor masses of 100 to 250 times that of the Sun. These events are exceedingly rare at low redshift, but are expected to be more common at high redshift because the mass distribution of the earliest stars was probably skewed to high values. Here we report the detection of two superluminous supernovae, at redshifts of 2.05 and 3.90, that have slowly evolving light curves. We estimate the rate of events at redshifts of 2 and 4 to be approximately ten times higher than the rate at low redshift. The extreme luminosities of superluminous supernovae extend the redshift limit for supernova detection using present technology, previously 2.36 (ref. 8), and provide a way of investigating the deaths of the first generation of stars to form after the Big Bang.