The death of massive stars produces a variety of supernovae, which are linked to the structure of the exploding stars. The detection of several precursor stars of type II supernovae has been reported (see, for example, ref. 3), but we do not yet have direct information on the progenitors of the hydrogen-deficient type Ib and Ic supernovae. Here we report that the peculiar type Ib supernova SN 2006jc is spatially coincident with a bright optical transient that occurred in 2004. Spectroscopic and photometric monitoring of the supernova leads us to suggest that the progenitor was a carbon-oxygen Wolf-Rayet star embedded within a helium-rich circumstellar medium. There are different possible explanations for this pre-explosion transient. It appears similar to the giant outbursts of luminous blue variable stars (LBVs) of 60-100 solar masses, but the progenitor of SN 2006jc was helium- and hydrogen-deficient (unlike LBVs). An LBV-like outburst of a Wolf-Rayet star could be invoked, but this would be the first observational evidence of such a phenomenon. Alternatively, a massive binary system composed of an LBV that erupted in 2004, and a Wolf-Rayet star exploding as SN 2006jc, could explain the observations.