Terahertz electromagnetic radiation is extremely useful for numerous applications, including imaging and spectroscopy. It is thus highly desirable to have an efficient table-top emitter covering the 1–30 THz window that is driven by a low-cost, low-power femtosecond laser oscillator. So far, all solid-state emitters solely exploit physics related to the electron charge and deliver emission spectra with substantial gaps. Here, we take advantage of the electron spin to realize a conceptually new terahertz source that relies on three tailored fundamental spintronic and photonic phenomena in magnetic metal multilayers: ultrafast photoinduced spin currents, the inverse spin-Hall effect and a broadband Fabry–Pérot resonance. Guided by an analytical model, this spintronic route offers unique possibilities for systematic optimization. We find that a 5.8-nm-thick W/CoFeB/Pt trilayer generates ultrashort pulses fully covering the 1–30 THz range. Our novel source outperforms laser-oscillator-driven emitters such as ZnTe(110) crystals in terms of bandwidth, terahertz field amplitude, flexibility, scalability and cost.