New results on the production of charged pions in p+p interactions are presented. The data come from a sample of 4.8 million inelastic events obtained with the NA49 detector at the CERN SPS at 158 GeV/c beam momentum. Pions are identified by energy loss measurement in a large TPC tracking system which covers a major fraction of the production phase space. Inclusive invariant cross sections are given on a grid of nearly 300 bins per charge over intervals from 0 to 2 GeV/c in transverse momentum and from 0 to 0.85 in Feynman x. The results are compared to existing data in overlapping energy ranges. ; Comment: 54 pages, 54 figures, accepted for publication in EPJC