Context. Although the Gaia catalogue on its own is a very powerful tool, it is the combination of this high-accuracy archive with other archives that will truly open up amazing possibilities for astronomical research. The advanced interoperation of archives is based on cross-matching, leaving the user with the feeling of working with one single data archive. The data retrieval should work not only across data archives but also across wavelength domains. The first step for a seamless access to the data is the computation of the cross-match between Gaia and external surveys. Aims. We describe the adopted algorithms and results of the pre-computed cross-match of the Gaia Data Release 2 (DR2) catalogue with dense surveys (Pan-STARRS1 DR1, 2MASS, SDSS DR9, GSC 2.3, URAT-1, allWISE, PPMXL, and APASS DR9) and sparse catalogues (Hipparcos2, Tycho-2, and RAVE 5). Methods. A new algorithm is developed specifically for sparse catalogues. Improvements and changes with respect to the algorithm adopted for DR1 are described in detail. Results. The outputs of the cross-match are part of the official Gaia DR2 catalogue. The global analysis of the cross-match results is also presented.