RESUMEN
The mergers of binary compact objects such as neutron stars and black holes are of central interest to several areas of astrophysics, including as the progenitors of gamma-ray bursts (GRBs)1, sources of high-frequency gravitational waves (GWs)2 and likely production sites for heavy-element nucleosynthesis by means of rapid neutron capture (the r-process)3. Here we present observations of the exceptionally bright GRB 230307A. We show that GRB 230307A belongs to the class of long-duration GRBs associated with compact object mergers4-6 and contains a kilonova similar to AT2017gfo, associated with the GW merger GW170817 (refs. 7-12). We obtained James Webb Space Telescope (JWST) mid-infrared imaging and spectroscopy 29 and 61 days after the burst. The spectroscopy shows an emission line at 2.15 microns, which we interpret as tellurium (atomic mass A = 130) and a very red source, emitting most of its light in the mid-infrared owing to the production of lanthanides. These observations demonstrate that nucleosynthesis in GRBs can create r-process elements across a broad atomic mass range and play a central role in heavy-element nucleosynthesis across the Universe.