For the vast majority of stars in the second Gaia data release, reliable distances cannot be obtained by inverting the parallax. A correct inference procedure must instead be used to account for the nonlinearity of the transformation and the asymmetry of the resulting probability distribution. Here we infer distances to essentially all 1.33 billion stars with parallaxes published in the second gaia data release. This is done using a weak distance prior that varies smoothly as a function of Galactic longitude and latitude according to a Galaxy model. The irreducible uncertainty in the distance estimate is characterized by the lower and upper bounds of an asymmetric confidence interval. Although more precise distances can be estimated for a subset of the stars using additional data (such as photometry), our goal is to provide purely geometric distance estimates, independent of assumptions about the physical properties of, or interstellar extinction towards, individual stars. We analyse the characteristics of the catalogue and validate it using clusters. The catalogue can be queried on the Gaia archive using ADQL at http://gea.esac.esa.int/archive/ and downloaded from http://www.mpia.de/~calj/gdr2_distances.html .