We report the discovery and monitoring of the near-infrared counterpart (AT2017gfo) of a binary neutron-star merger event detected as a gravitational wave source by Advanced LIGO/Virgo (GW170817) and as a short gamma-ray burst by Fermi/GBM and Integral/SPI-ACS (GRB170817A). The evolution of the transient light is consistent with predictions for the behaviour of a kilonova/macronova, powered by the radioactive decay of massive neutron-rich nuclides created via r-process nucleosynthesis in the neutron-star ejecta. In particular, evidence for this scenario is found from broad features seen in Hubble Space Telescope infrared spectroscopy, similar to those predicted for lanthanide dominated ejecta, and the much slower evolution in the near-infrared Ks-band compared to the optical. This indicates that the late-time light is dominated by high-opacity lanthanide-rich ejecta, suggesting nucleosynthesis to the 3rd r-process peak (atomic masses A~195). This discovery confirms that neutron-star mergers produce kilo-/macronovae and that they are at least a major - if not the dominant - site of rapid neutron capture nucleosynthesis in the universe.