Chondrules are the millimetre-scale, previously molten, spherules found in most meteorites. Before chondrules formed, large differentiating planetesimals had already accreted. Volatile-rich olivine reveals that chondrules formed in extremely solid-rich environments, more like impact plumes than the solar nebula. The unique chondrules in CB chondrites probably formed in a vapour-melt plume produced by a hypervelocity impact with an impact velocity greater than 10 kilometres per second. An acceptable formation model for the overwhelming majority of chondrules, however, has not been established. Here we report that impacts can produce enough chondrules during the first five million years of planetary accretion to explain their observed abundance. Building on a previous study of impact jetting, we simulate protoplanetary impacts, finding that material is melted and ejected at high speed when the impact velocity exceeds 2.5 kilometres per second. Using a Monte Carlo accretion code, we estimate the location, timing, sizes, and velocities of chondrule-forming impacts. Ejecta size estimates indicate that jetted melt will form millimetre-scale droplets. Our radiative transfer models show that these droplets experience the expected cooling rates of ten to a thousand kelvin per hour. An impact origin for chondrules implies that meteorites are a byproduct of planet formation rather than leftover building material.