51 Oph is a Herbig Ae/Be star that exhibits strong near-infrared CO ro-vibrational emission at 2.3 micron, most likely originating in the innermost regions of a circumstellar disc. We aim to obtain the physical and geometrical properties of the system by spatially resolving the circumstellar environment of the inner gaseous disc. We used the second-generation VLTI/GRAVITY to spatially resolve the continuum and the CO overtone emission. We obtained data over 12 baselines with the auxiliary telescopes and derive visibilities, and the differential and closure phases as a function of wavelength. We used a simple LTE ring model of the CO emission to reproduce the spectrum and CO line displacements. Our interferometric data show that the star is marginally resolved at our spatial resolution, with a radius of 10.58+-2.65 Rsun.The K-band continuum emission from the disc is inclined by 63+-1 deg, with a position angle of 116+-1 deg, and 4+-0.8 mas (0.5+-0.1 au) across. The visibilities increase within the CO line emission, indicating that the CO is emitted within the dust-sublimation radius.By modelling the CO bandhead spectrum, we derive that the CO is emitted from a hot (T=1900-2800 K) and dense (NCO=(0.9-9)x10^21 cm^-2) gas. The analysis of the CO line displacement with respect to the continuum allows us to infer that the CO is emitted from a region 0.10+-0.02 au across, well within the dust-sublimation radius. The inclination and position angle of the CO line emitting region is consistent with that of the dusty disc. Our spatially resolved interferometric observations confirm the CO ro-vibrational emission within the dust-free region of the inner disc. Conventional disc models exclude the presence of CO in the dust-depleted regions of Herbig AeBe stars. Ad hoc models of the innermost disc regions, that can compute the properties of the dust-free inner disc, are therefore required.