Context. Molecular hydrogen in the interstellar medium (ISM) of high-redshift galaxies can be detected directly from its UV absorption imprinted in the spectrum of background quasars. Associated absorption from H and metals allow for the study of the chemical enrichment of the gas, while the analysis of excited species and molecules make it possible to infer the physical state of the ISM gas. In addition, given the numerous H 2 lines usually detected, these absorption systems are unique tools to constrain the cosmological variation of the proton-to-electron mass ratio, µ. Aims. We intend to study the chemical and physical state of the gas in the H 2 -bearing cloud at z abs = 2.658601 towards the quasar Q J 0643−5041 (z em = 3.09) and to derive a useful constraint on the variation of µ. Methods. We use high signal-to-noise ratio, high-resolution VLT-UVES data of Q J 0643−5041 amounting to a total of more than 23 h exposure time and fit the H , metals, and H 2 absorption features with multiple-component Voigt profiles. We study the relative populations of H 2 rotational levels and the fine-structure excitation of neutral carbon to determine the physical conditions in the H 2 -bearing cloud. Results. We find some evidence for part of the quasar broad-line emission region not being fully covered by the H 2 -bearing cloud. We measure a total neutral hydrogen column density of log N(H )(cm −2 ) = 21.03 ± 0.08. Molecular hydrogen is detected in several rotational levels, possibly up to J = 7, in a single component. The corresponding molecular fraction is log f = −2.19 +0.07 −0.08 , where f = 2N(H 2 )/(2N(H 2 ) + N(H )). The H 2 Doppler parameter is of the order of 1.5 km s −1 for J = 0, 1, and 2 and larger for J > 2. The molecular component has a kinetic temperature of T kin 80 K, which yields a mean thermal velocity of ∼1 km s −1 , consistent with the Doppler broadening of the lines. The UV ambient flux is of the order of the mean ISM Galactic flux. We discuss the possible detection of HD and derive an upper limit of log N(HD) 13.65 ± 0.07 leading to log HD/(2 × H 2 ) −5.19 ± 0.07, which is consistently lower than the primordial D/H ratio. Metals span ∼210 km s −1 with [Zn/H] = −0.91 ± 0.09 relative to solar, with iron depleted relative to zinc [Zn/Fe] = 0.45 ± 0.06, and with the rare detection of copper. We follow the procedures used in our previous works to derive a constraint on the cosmological variation of µ, ∆µ/µ = (7.4 ± 4.3 stat ± 5.1 syst ) × 10 −6 .