  Gamma-ray bursts (GRBs) are flashes of high-energy radiation arising from
energetic cosmic explosions. Bursts of long (>2 s) duration are produced by the
core-collapse of massive stars, those of short (< 2 s) duration by the merger
of two neutron stars (NSs). A third class of events with hybrid high-energy
properties was identified, but never conclusively linked to a stellar
progenitor. The lack of bright supernovae rules out typical core-collapse
explosions, but their distance scales prevent sensitive searches for direct
signatures of a progenitor system. Only tentative evidence for a kilonova has
been presented. Here we report observations of the exceptionally bright
GRB211211A that classify it as a hybrid event and constrain its distance scale
to only 346 Mpc. Our measurements indicate that its lower-energy (from
ultraviolet to near-infrared) counterpart is powered by a luminous (~1E42
erg/s) kilonova possibly formed in the ejecta of a compact binary merger.
