Fast radio bursts (FRBs) are highly dispersed, millisecond-duration radio bursts1-3. Recent observations of a Galactic FRB4-8 suggest that at least some FRBs originate from magnetars, but the origin of cosmological FRBs is still not settled. Here we report the detection of 1,863 bursts in 82 h over 54 days from the repeating source FRB 20201124A (ref. 9). These observations show irregular short-time variation of the Faraday rotation measure (RM), which scrutinizes the density-weighted line-of-sight magnetic field strength, of individual bursts during the first 36 days, followed by a constant RM. We detected circular polarization in more than half of the burst sample, including one burst reaching a high fractional circular polarization of 75%. Oscillations in fractional linear and circular polarizations, as well as polarization angle as a function of wavelength, were detected. All of these features provide evidence for a complicated, dynamically evolving, magnetized immediate environment within about an astronomical unit (AU; Earth-Sun distance) of the source. Our optical observations of its Milky-Way-sized, metal-rich host galaxy10-12 show a barred spiral, with the FRB source residing in a low-stellar-density interarm region at an intermediate galactocentric distance. This environment is inconsistent with a young magnetar engine formed during an extreme explosion of a massive star that resulted in a long gamma-ray burst or superluminous supernova.