Measurements of two-particle correlation functions and the first five azimuthal harmonics, v(1) to v(5), are presented, using 28 nb(-1) of p + Pb collisions at a nucleon-nucleon center-of-mass energy of root s(NN) = 5.02 TeV measured with the ATLAS detector at the LHC. Significant long-range "ridgelike" correlations are observed for pairs with small relative azimuthal angle (|Delta phi| < pi/3) and back-to-back pairs (|Delta phi| > 2 pi/3) over the transverse momentum range 0.4 < p(T) < 12 GeV and in different intervals of event activity. The event activity is defined by either the number of reconstructed tracks or the total transverse energy on the Pb-fragmentation side. The azimuthal structure of such long-range correlations is Fourier decomposed to obtain the harmonics v(n) as a function of p(T) and event activity. The extracted v(n) values for n = 2 to 5 decrease with n. The v(2) and v(3) values are found to be positive in the measured p(T) range. The v(1) is also measured as a function of p(T) and is observed to change sign around p(T) approximate to 1.5-2.0 GeV and then increase to about 0.1 for pT > 4 GeV. The v(2)(p(T)), v(3)(p(T)), and v(4)(p(T)) are compared to the v(n) coefficients in Pb + Pb collisions at root s(NN) = 2.76 TeV with similar event multiplicities. Reasonable agreement is observed after accounting for the difference in the average p(T) of particles produced in the two collision systems.