'Oumuamua (1I/2017 U1) is the first known object of interstellar origin to have entered the Solar System on an unbound and hyperbolic trajectory with respect to the Sun. Various physical observations collected during its visit to the Solar System showed that it has an unusually elongated shape and a tumbling rotation state and that the physical properties of its surface resemble those of cometary nuclei, even though it showed no evidence of cometary activity. The motion of all celestial bodies is governed mostly by gravity, but the trajectories of comets can also be affected by non-gravitational forces due to cometary outgassing. Because non-gravitational accelerations are at least three to four orders of magnitude weaker than gravitational acceleration, the detection of any deviation from a purely gravity-driven trajectory requires high-quality astrometry over a long arc. As a result, non-gravitational effects have been measured on only a limited subset of the small-body population. Here we report the detection, at 30σ significance, of non-gravitational acceleration in the motion of 'Oumuamua. We analyse imaging data from extensive observations by ground-based and orbiting facilities. This analysis rules out systematic biases and shows that all astrometric data can be described once a non-gravitational component representing a heliocentric radial acceleration proportional to r-2 or r-1 (where r is the heliocentric distance) is included in the model. After ruling out solar-radiation pressure, drag- and friction-like forces, interaction with solar wind for a highly magnetized object, and geometric effects originating from 'Oumuamua potentially being composed of several spatially separated bodies or having a pronounced offset between its photocentre and centre of mass, we find comet-like outgassing to be a physically viable explanation, provided that 'Oumuamua has thermal properties similar to comets.