Context : Aims : We estimate the mass of the inner ( < 20 kpc ) Milky Way and the axis ratio of its inner dark matter halo using globular clusters as tracers . At the same time , we constrain the distribution in phase-space of the globular cluster system around the Galaxy . Methods : We use the Gaia Data Release 2 catalogue of 75 globular clusters ’ proper motions and recent measurements of the proper motions of another 20 distant clusters obtained with the Hubble Space Telescope . We describe the globular cluster system with a distribution function ( DF ) with two components : a flat , rotating disc-like one and a rounder , more extended halo-like one . While fixing the Milky Way ’ s disc and bulge , we let the mass and shape of the dark matter halo and we fit these two parameters , together with six others describing the DF , with a Bayesian method . Results : We find the mass of the Galaxy within 20 kpc to be M ( < 20 { kpc } ) = 1.91 ^ { +0.18 } _ { -0.17 } \times 10 ^ { 11 } M _ { \odot } , of which M _ { DM } ( < 20 { kpc } ) = 1.37 ^ { +0.18 } _ { -0.17 } \times 10 ^ { 11 } M _ { \odot } is in dark matter , and the density axis ratio of the dark matter halo to be q = 1.30 \pm 0.25 . Assuming a concentration-mass relation , this implies a virial mass M _ { vir } = 1.3 \pm 0.3 \times 10 ^ { 12 } M _ { \odot } . Our analysis rules out oblate ( q < 0.8 ) and strongly prolate halos ( q > 1.9 ) with 99 % probability . Our preferred model reproduces well the observed phase-space distribution of globular clusters and has a disc component that closely resembles that of the Galactic thick disc . The halo component follows a power-law density profile \rho \propto r ^ { -3.3 } , has a mean rotational velocity of V _ { rot } \simeq - 14 km s ^ { -1 } at 20 kpc , and has a mildly radially biased velocity distribution ( \beta \simeq 0.2 \pm 0.07 , which varies significantly with radius only within the inner 15 kpc ) . We also find that our distinction between disc and halo clusters resembles , although not fully , the observed distinction in metal-rich ( [ Fe/H ] > -0.8 ) and metal-poor ( [ Fe/H ] \leq - 0.8 ) cluster populations . Conclusions :