We present the first Gogny-Hartree-Fock-Bogoliubov (HFB) model which reproduces nuclear masses with an accuracy comparable with the best mass formulas. In contrast with the Skyrme-HFB nuclear-mass models, an explicit and self-consistent account of all the quadrupole correlation energies are included within the 5D collective Hamiltonian approach. The final rms deviation with respect to the 2149 measured masses is 798 keV. In addition, the new Gogny force is shown to predict nuclear and neutron matter properties in agreement with microscopic calculations based on realistic two- and three-body forces.