Gravitational-wave detections provide a novel way to determine the Hubble constant1-3, which is the current rate of expansion of the Universe. This `standard siren' method, with the absolute distance calibration provided by the general theory of relativity, was used to measure the Hubble constant using the gravitational-wave detection of the binary neutron-star merger, GW170817, by the Laser Interferometer Gravitational-Wave Observatory (LIGO) and Virgo4, combined with optical identification of the host galaxy5,6 NGC 4993. This independent measurement is of particular interest given the discrepancy between the value of the Hubble constant determined using type Ia supernovae via the local distance ladder (73.24 ± 1.74 kilometres per second per megaparsec) and the value determined from cosmic microwave background observations (67.4 ± 0.5 kilometres per second per megaparsec): these values differ7,8 by about 3σ. Local distance ladder observations may achieve a precision of one per cent within five years, but at present there are no indications that further observations will substantially reduce the existing discrepancies9. Here we show that additional gravitational-wave detections by LIGO and Virgo can be expected to constrain the Hubble constant to a precision of approximately two per cent within five years and approximately one per cent within a decade. This is because observing gravitational waves from the merger of two neutron stars, together with the identification of a host galaxy, enables a direct measurement of the Hubble constant independent of the systematics associated with other available methods. In addition to clarifying the discrepancy between existing low-redshift (local ladder) and high-redshift (cosmic microwave background) measurements, a precision measurement of the Hubble constant is of crucial value in elucidating the nature of dark energy10,11.