Fast radio bursts (FRBs) are very short and bright transients visible over extragalactic distances. The radio pulse undergoes dispersion caused by free electrons along the line of sight, most of which are associated with the large-scale structure (LSS). The total dispersion measure therefore increases with the line of sight and provides a distance estimate to the source. We present the first measurement of the Hubble constant using the dispersion measure -- redshift relation of FRBs with identified host counterpart and corresponding redshift information. A sample of nine currently available FRBs yields a constraint of $H_0 = 62.3 pm 9.1 ,rm{km} ,rm{s}^{-1},rm{Mpc}^{-1}$, accounting for uncertainty stemming from the LSS, host halo and Milky Way contributions to the observed dispersion measure. The main current limitation is statistical, and we estimate that a few hundred events with corresponding redshifts are sufficient for a per cent measurement of $H_0$. This is a number well within reach of ongoing FRB searches. We perform a forecast using a realistic mock sample to demonstrate that a high-precision measurement of the expansion rate is possible without relying on other cosmological probes. FRBs can therefore arbitrate the current tension between early and late time measurements of $H_0$ in the near future.