A measurement of the double-differential cross-section for the production of charged pions in proton-tantalum collisions emitted at large angles from the incoming beam direction is presented. The data were taken in 2002 with the HARP detector in the T9 beam line of the CERN PS. The pions were produced by proton beams in a momentum range from 3 GeV/c to 12 GeV/c hitting a tantalum target with a thickness of 5% of a nuclear interaction length. The angular and momentum range covered by the experiment (100 MeV/c ≤ p< 800 MeV/c and 0.35 rad ≤ θ< 2.15 rad) is of particular importance for the design of a neutrino factory. The produced particles were detected using a small-radius cylindrical time projection chamber (TPC) placed in a solenoidal magnet. Track recognition, momentum determination and particle identification were all performed based on the measurements made with the TPC. An elaborate system of detectors in the beam line ensured the identification of the incident particles. Results are shown for the double-differential cross-sections d 2σ/dpdθ at four incident proton beam momenta (3 GeV/c, 5 GeV/c, 8 GeV/c and 12 GeV/c). In addition, the pion yields within the acceptance of typical neutrino factory designs are shown as a function of beam momentum. The measurement of these yields within a single experiment eliminates most systematic errors in the comparison between rates at different beam momenta and between positive and negative pion production.