The dispersive sweep of fast radio bursts (FRBs) has been used to probe the ionized baryon content of the intergalactic medium1, which is assumed to dominate the total extragalactic dispersion. Although the host-galaxy contributions to the dispersion measure appear to be small for most FRBs2, in at least one case there is evidence for an extreme magneto-ionic local environment3,4 and a compact persistent radio source5. Here we report the detection and localization of the repeating FRB 20190520B, which is co-located with a compact, persistent radio source and associated with a dwarf host galaxy of high specific-star-formation rate at a redshift of 0.241 ± 0.001. The estimated host-galaxy dispersion measure of approximately 903−111+72 parsecs per cubic centimetre, which is nearly an order of magnitude higher than the average of FRB host galaxies2,6, far exceeds the dispersion-measure contribution of the intergalactic medium. Caution is thus warranted in inferring redshifts for FRBs without accurate host-galaxy identifications.