Measurements of the double-differential proton production cross-section d2σ/dpdΩ in the range of momentum 0.5 GeV/c⩽p<8.0 GeV/c and angle 0.05 rad⩽θ<0.25 rad in collisions of charged pions and protons on beryllium, carbon, aluminium, copper, tin, tantalum, and lead are presented. The data were taken with the large acceptance HARP detector in the T9 beam line of the CERN Proton Synchrotron. Incident particles were identified by an elaborate system of beam detectors and impinged on a target of 5% of a nuclear interaction length. The tracking and identification of the produced particles was performed using the forward spectrometer of the HARP experiment. Results are obtained for the double-differential cross-sections mainly at four incident beam momenta (3,5,8, and 12 GeV/c). Measurements are compared with predictions of the geant4 and mars Monte Carlo generators.