The modification of the production of J/ψ , ψ(2S) , and Υ(nS) ( n=1,2,3 ) in p+Pb collisions with respect to their production in pp collisions has been studied. The p+Pb and pp datasets used in this paper correspond to integrated luminosities of 28nb-1 and 25pb-1 respectively, collected in 2013 and 2015 by the ATLAS detector at the LHC, both at a centre-of-mass energy per nucleon pair of 5.02 TeV. The quarkonium states are reconstructed in the dimuon decay channel. The yields of J/ψ and ψ(2S) are separated into prompt and non-prompt sources. The measured quarkonium differential cross sections are presented as a function of rapidity and transverse momentum, as is the nuclear modification factor, RpPb for J/ψ and Υ(nS) . No significant modification of the J/ψ production is observed while Υ(nS) production is found to be suppressed at low transverse momentum in p+Pb collisions relative to pp collisions. The production of excited charmonium and bottomonium states is found to be suppressed relative to that of the ground states in central p+Pb collisions.