The decays B+-> J/psi pi(+)pi(-)K(+)are studied using a data set corresponding to an integrated luminosity of 9 fb(-1)collected with the LHCb detector in proton-proton collisions between 2011 and 2018. Precise measurements of the ratios of branching fractions with the intermediate psi(2)(3823), chi(c1)(3872) and psi(2S) states are reported. The values areBB+->psi 2(">3823K+xB psi 2(">3823 -> J/psi pi+pi-BB+->chi c1>3872K+xB chi c1>3872 -> J/psi pi+pi-=>3.56 +/- 0.67 +/- 0.11x10-2,BB+->psi 2>3823K+xB psi 2>3823 -> J/psi pi+pi-BB+->psi>2SK+xB psi>2S -> J/psi pi+pi-=>1.31 +/- 0.25 +/- 0.04x10-3,BB+->chi c1>3872K+xB chi c1>3872 -> J/psi pi+pi-BB+->psi>2SK+xB psi>2S -> J/psi pi+pi-= where the first uncertainty is statistical and the second is systematic. The decay of B+->psi(2)(3823)K(+)with psi(2)(3823)-> J/psi pi(+)pi(-)is observed for the first time with a significance of 5.1 standard deviations. The mass differences between the psi(2)(3823), chi(c1)(3872) and psi(2S) states are measured to be m chi c1>3872-m psi 2>3823=47. 50 +/- 0.53 +/- 0.13MeV/c2,m psi 2 2S=185.49 +/- 0.06 +/- 0.03MeV/c2, resulting in the most precise determination of the chi(c1)(3872) mass. The width of the psi(2)(3823) state is found to be below 5.2 MeV at 90% confidence level. The Breit-Wigner width of the chi(c1)(3872) state is measured to be Gamma chi c13872BW=0.96-0.18+0.19 +/- 0.21MeV={0.96}_{-0.18}<^>{+0.19}\pm 0.21\;\mathrm{MeV} which is inconsistent with zero by 5.5 standard deviations.