Erbium ions embedded in crystals have unique properties for quantum information processing, because of their optical transition at 1.5 μm and of the large magnetic moment of their effective spin-1/2 electronic ground state. Most applications of erbium require, however, long electron spin coherence times, and this has so far been missing. Here, by selecting a host matrix with a low nuclear-spin density (CaWO4) and by quenching the spectral diffusion due to residual paramagnetic impurities at millikelvin temperatures, we obtain a 23-ms coherence time on the Er3+ electron spin transition. This is the longest Hahn echo electron spin coherence time measured in a material with a natural abundance of nuclear spins and on a magnetically sensitive transition. Our results establish Er3+:CaWO4 as a potential platform for quantum networks.