Results are presented from the measurement by ATLAS of long-range (| Δ η| > 2) dihadron angular correlations in s=8 and 13 TeV pp collisions containing a Z boson. The analysis is performed using 19.4 fb - 1 of s=8 TeV data recorded during Run 1 of the LHC and 36.1 fb - 1 of s=13 TeV data recorded during Run 2. Two-particle correlation functions are measured as a function of relative azimuthal angle over the relative pseudorapidity range 2 < | Δ η| < 5 for different intervals of charged-particle multiplicity and transverse momentum. The measurements are corrected for the presence of background charged particles generated by collisions that occur during one passage of two colliding proton bunches in the LHC. Contributions to the two-particle correlation functions from hard processes are removed using a template-fitting procedure. Sinusoidal modulation in the correlation functions is observed and quantified by the second Fourier coefficient of the correlation function, v2 , 2, which in turn is used to obtain the single-particle anisotropy coefficient v2. The v2 values in the Z-tagged events, integrated over 0.5 < pT< 5 GeV, are found to be independent of multiplicity and s, and consistent within uncertainties with previous measurements in inclusive pp collisions. As a function of charged-particle pT, the Z-tagged and inclusive v2 values are consistent within uncertainties for pT< 3 GeV.