Particle accelerators driven by laser-generated terahertz (THz) pulses promise unprecedented control over the energy–time phase space of particle bunches compared with conventional radiofrequency technology. Here we demonstrate acceleration of a relativistic electron beam in a THz-driven linear accelerator. Narrowband THz pulses were tuned to the phase-velocity-matched operating frequency of a rectangular dielectric-lined waveguide for extended collinear interaction with 35 MeV, 60 pC electron bunches, imparting multicycle energy modulation to chirped (6 ps) bunches and injection phase-dependent energy gain (up to 10 keV) to subcycle (2 ps) bunches. These proof-of-principle results establish a route to whole-bunch linear acceleration of subpicosecond particle beams, directly applicable to scaled-up and multistaged concepts capable of preserving beam quality, thus marking a key milestone for future THz-driven acceleration of relativistic beams