The Glashow resonance describes the resonant formation of a W- boson during the interaction of a high-energy electron antineutrino with an electron1, peaking at an antineutrino energy of 6.3 petaelectronvolts (PeV) in the rest frame of the electron. Whereas this energy scale is out of reach for currently operating and future planned particle accelerators, natural astrophysical phenomena are expected to produce antineutrinos with energies beyond the PeV scale. Here we report the detection by the IceCube neutrino observatory of a cascade of high-energy particles (a particle shower) consistent with being created at the Glashow resonance. A shower with an energy of 6.05 ± 0.72 PeV (determined from Cherenkov radiation in the Antarctic Ice Sheet) was measured. Features consistent with the production of secondary muons in the particle shower indicate the hadronic decay of a resonant W- boson, confirm that the source is astrophysical and provide improved directional localization. The evidence of the Glashow resonance suggests the presence of electron antineutrinos in the astrophysical flux, while also providing further validation of the standard model of particle physics. Its unique signature indicates a method of distinguishing neutrinos from antineutrinos, thus providing a way to identify astronomical accelerators that produce neutrinos via hadronuclear or photohadronic interactions, with or without strong magnetic fields. As such, knowledge of both the flavour (that is, electron, muon or tau neutrinos) and charge (neutrino or antineutrino) will facilitate the advancement of neutrino astronomy.