Measurements of the double-differential π± production cross section in the range of momentum 100⩽p⩽800 MeV/c and angle 0.35⩽θ⩽2.15 rad using π± beams incident on beryllium, aluminum, carbon, copper, tin, tantalum, and lead targets are presented. The data were taken with the large-acceptance hadron production (HARP) detector in the T9 beam line of the CERN Proton Synchrotron. The secondary pions were produced by beams in a momentum range from 3 to 12.9GeV/c hitting a solid target with a thickness of 5% of a nuclear interaction length. The tracking and identification of the produced particles was performed using a small-radius cylindrical time projection chamber placed inside a solenoidal magnet. Incident particles were identified by an elaborate system of beam detectors. Results are obtained for the double-differential cross sections d2σ/dp dθ at six incident-beam momenta. Data at 3,5,8, and 12GeV/c are available for all targets, while additional data at 8.9 and 12.9GeV/c were taken in positive particle beams on Be and Al targets, respectively. The measurements are compared with several generators of GEANT4 and the MARS Monte Carlo simulation.