The measurement of the mass differences for systems bound by the strong force has reached a very high precision with protons and anti-protons. The extension of such measurement from (anti-)baryons to (anti-)nuclei allows one to probe any difference in the interactions between nucleons and anti-nucleons encoded in the (anti-)nuclei masses. This force is a remnant of the underlying strong interaction among quarks and gluons and can be described by effective theories, but cannot yet be directly derived from quantum chromodynamics. Here we report a measurement of the difference between the ratios of the mass and charge of deuterons (d) and anti-deuterons (bar d), and He3 and bar He3 nuclei carried out with the ALICE (A Large Ion Collider Experiment) detector in Pb–Pb collisions at a centre-of-mass energy per nucleon pair of 2.76 TeV. Our direct measurement of the mass-over-charge differences confirms CPT invariance to an unprecedented precision in the sector of light nuclei. This fundamental symmetry of nature, w