The production cross-section of the χc1(3872) state relative to the ψ(2S) meson is measured using proton-proton collision data collected with the LHCb experiment at centre-of-mass energies of s = 8 and 13 TeV, corresponding to integrated luminosities of 2.0 and 5.4 fb−1, respectively. The two mesons are reconstructed in the J/ψπ+π− final state. The ratios of the prompt and nonprompt χc1(3872) to ψ(2S) production cross-sections are measured as a function of transverse momentum, pT, and rapidity, y, of the χc1(3872) and ψ(2S) states, in the kinematic range 4 < pT< 20 GeV/c and 2.0 < y < 4.5. The prompt ratio is found to increase with pT, independently of y. For the prompt component, the double ratio of the χc1(3872) and ψ(2S) production cross-sections between 13 and 8 TeV is observed to be consistent with unity, independent of pT and centre-of-mass energy. [Figure not available: see fulltext.].