Precise radial-velocity measurements for data acquired with the HARPS spectrograph infer that three planets orbit the M 4 dwarf star GJ 876. In particular, we confirm the existence of planet d, which orbits every 1.93785 days. We find that its orbit may have significant eccentricity (e = 0.14), and deduce a more accurate estimate of its minimum mass of 6.3 M ⊕ . Dynamical modeling of the HARPS measurements combined with literature velocities from the Keck Observatory strongly constrain the orbital inclinations of the b and c planets. We find that i b = 48.9 • ± 1.0 • and i c = 48.1 • ± 2.1 • , which infers the true planet masses of M b = 2.64 ± 0.04 M Jup and M c = 0.83 ± 0.03 M Jup , respectively. Radial velocities alone, in this favorable case, can therefore fully determine the orbital architecture of a multi-planet system, without the input from astrometry or transits. The orbits of the two giant planets are nearly coplanar, and their 2:1 mean motion resonance ensures stability over at least 5 Gyr. The libration amplitude is smaller than 2 • , suggesting that it was damped by some dissipative process during planet formation. The system has space for a stable fourth planet in a 4:1 mean motion resonance with planet b, with a period around 15 days. The radial velocity measurements constrain the mass of this possible additional planet to be at most that of the Earth.