We present time-resolved 10.4 m Gran Telescopio Canarias and 4.2 m William Herschel Telescope intermediate resolution spectroscopy of the X-ray transient MAXI J1820+070 (=ASASSN-18ey) obtained during its decline to the quiescent state. Cross-correlation of the 21 individual spectra against late-type templates reveals a sinusoidal velocity modulation with a period of 0.68549 ± 0.00001 day and semi-amplitude of 417.7 ± 3.9 km s−1. We derive a mass function f(M) = 5.18 ± 0.15 M ☉, dynamically confirming the black hole (BH) nature of the compact object. Our analysis of the stellar absorption features supports a K3-5 spectral classification for the donor star, which contributes ≈20% of the total flux at 5200─6800 Å. The photometric 0.703 ± 0.003 day periodicity observed during outburst is 2.6% longer than the orbital period supporting the presence of a superhump modulation in the outburst light curves. In line with this interpretation, we constrain the binary mass ratio to be q ≃ 0.12. In addition, we observe a sharp increase in the Hα emission line equivalent width during inferior conjunction of the donor star that we interpret as a grazing eclipse of the accretion disk and allows us to constrain the binary inclination to i ≳ 69°. On the other hand, the absence of X-ray eclipses during outburst imply i ≲ 77°. These inclination limits, together with our dynamical solution, lead to a BH mass in the range 7─8 M ☉. We also measure a systemic velocity γ = −21.6 ± 2.3 km s−1, which, combined with the Gaia second data release proper motion and parallax, implies a large peculiar velocity ∼100 km s−1.