We analyze a map of the Galactic ridge X-ray emission (GRXE) constructed in the 3-20 keV energy band from RXTE/PCA scan and slew observations. We show that the GRXE intensity closely follows the Galactic near-infrared surface brightness and thus traces the Galactic stellar mass distribution. The GRXE consists of two spatial components which can be identified with the bulge/bar and the disk of the Galaxy. The parameters of these components determined from X-ray data are compatible with those derived from near-infrared data. The inferred ratio of X-ray to near-infrared surface brightness I(3-20 keV) (1e-11 erg/s/cm2/deg2)/I_(3.5micron)(MJy/sr)=0.26+/-0.05, and the ratio of X-ray to near-infrared luminosity L_(3-20 keV)/L_(3-4 micron)=(4.1+/-0.3)e-5. The corresponding ratio of the 3-20 keV luminosity to the stellar mass is L_x/M_Sun= (3.5pm0.5) 10^{27} erg/s, which agrees within the uncertainties with the cumulative emissivity per unit stellar mass of point X-ray sources in the Solar neighborhood, determined in an accompanying paper (Sazonov et al.). This suggests that the bulk of the GRXE is composed of weak X-ray sources, mostly cataclysmic variables and coronally active binaries. The fractional contributions of these classes of sources to the total X-ray emissivity determined from the Solar neighborhood data can also explain the GRXE energy spectrum. Based on the luminosity function of local X-ray sources we predict that in order to resolve 90% of the GRXE into discrete sources a sensitivity limit of ~10^{-16} erg/s/cm2 (2--10 keV) will need to be reached in future observations.