  A study of the lineshape of the $\chi_{c1}(3872)$ state is made using a data
sample corresponding to an integrated luminosity of $3\,$fb$^{-1}$ collected in
$pp$ collisions at centre-of-mass energies of 7 and 8\,TeV with the LHCb
detector. Candidate $\chi_{c1}(3872)$ and $\psi(2S)$ mesons from b-hadron
decays are selected in the $ J/\psi \pi^+ \pi^-$ decay mode. Describing the
{\mbox{lineshape}} with a Breit--Wigner function, the mass splitting between
the $\chi_{c1}(3872)$ and $\psi(2S)$ states, $\Delta m$, and the width of the
$\chi_{c1}(3872)$ state, $\Gamma_{\mathrm{BW}}$, are determined to be
\begin{eqnarray*} \Delta m & = & 185.598 \pm 0.067 \pm 0.068\, \mathrm{MeV} \,,
\\ \Gamma_{\mathrm{BW}} & = & \phantom{00}1.39\phantom{0} \pm 0.24\phantom{0}
\pm 0.10\phantom{0} \mathrm{MeV} \,, \end{eqnarray*} where the first
uncertainty is statistical and the second systematic. Using a Flatt\'e-inspired
model, the mode and full width at half maximum of the lineshape are determined
to be \begin{eqnarray*} \mathrm{mode} & =
3871.69^{\,+\,0.00\,+\,0.05}_{\,-\,0.04\,-\,0.13} &\mathrm{MeV} \\
\mathrm{FWHM} & = 0.22^{\,+\,0.07\,+\,0.11}_{\,-\,0.06\,-\,0.13}& \mathrm{MeV}
. \end{eqnarray*} An investigation of the analytic structure of the Flatt\'e
amplitude reveals a pole structure, which is compatible with a quasi-bound
$D^0\bar{D}^{*0}$ state but a quasi-virtual state is still allowed at the level
of $2$ standard deviations.
