An increasing number of observations have shown that gaseous debris discs are not an exception. However, until now we only knew of cases around A stars. Here we present the first detection of 12CO (2-1) disc emission around an F star, HD 181327, obtained with ALMA observations at 1.3 mm. The continuum and CO emission are resolved into an axisymmetric disc with ring-like morphology. Using a Markov chain Monte Carlo method coupled with radiative transfer calculations we study the dust and CO mass distribution. We find the dust is distributed in a ring with a radius of 86.0 +- 0.4 AU and a radial width of 23.2 +- 1.0 AU. At this frequency the ring radius is smaller than in the optical, revealing grain size segregation expected due to radiation pressure. We also report on the detection of low level continuum emission beyond the main ring out to ~200 AU. We model the CO emission in the non-LTE regime and we find that the CO is co-located with the dust, with a total CO gas mass ranging between 1.2x10^-6 Mearth and 2.9x10^-6 Mearth, depending on the gas kinetic temperature and collisional partners densities. The CO densities and location suggest a secondary origin, i.e. released from icy planetesimals in the ring. We derive a CO+CO2 cometary composition that is consistent with Solar system comets. Due to the low gas densities it is unlikely that the gas is shaping the dust distribution.