More than 4 orders of magnitude of cavity-linewidth narrowing in a rare-earth-ion-doped crystal cavity, emanating from strong intracavity dispersion caused by off-resonant interaction with dopant ions, is demonstrated. The dispersion profiles are engineered using optical pumping techniques creating significant semipermanent but reprogrammable changes of the rare-earth absorption profiles. Several cavity modes are shown within the spectral transmission window. Several possible applications of this phenomenon are discussed.