Context. The Gaia mission has provided the largest catalogue ever of sources with tangential velocity information. However, it is difficult to use this catalogue for dynamical studies because most of the stars lack line-of-sight velocity measurements. Recently, we presented a selection of ∼107 halo stars with accurate distances that were selected based on their photometry and proper motions. Aims. Using this sample, we model the tail of the velocity distribution in the stellar halo locally and as a function of distance. Our goal is to measure the escape velocity, and based on this, to constrain the mass of our Galaxy. Methods. We fitted the tail of the velocity distribution with a power-law distribution, a commonly used approach that has long been established. For the first time, we used tangential velocities that were accurately measured for an unprecedented number of halo stars to estimate the escape velocity. Results. In the solar neighbourhood, we obtain a very precise estimate of the escape velocity, which is 497−8+8 km s−1. This estimate is most likely biased low, our best guess is by 10%. As a result, the true escape velocity is most likely closer to 550 km s−1. The escape velocity directly constrains the total mass of the Milky Way. To find the best-fitting halo mass and concentration parameter, we adjusted the dark (spherical Navarro-Frenk-White) halo of a realistic Milky Way potential while keeping the circular velocity at the solar radius fixed at vc(R⊙) = 232.8 km s−1. The resulting halo parameters are M200+10% = 1.11−0.07+0.08 · 1012 M⊙, and the concentration parameter is c+10% = 11.8−0.3+0.3, where we use the explicit notation to indicate that they are corrected for the 10% bias. The slope of the escape velocity with galactocentric distance is as expected in the inner Galaxy based on Milky Way models. Curiously, we find a disagreement beyond the solar radius where the estimated escape velocity is higher than at the solar radius. This result is likely an effect of a change in the shape of the velocity distribution and could be related to the presence of velocity clumps. A tentative analysis of the escape velocity as a function of (R, z) shows that the slope is shallower than expected for a spherical halo when standard values are used for the characteristic parameters describing the galactic disc.