We report the final optical identifications of the medium-depth (~60 ksec), contiguous (2 deg^2) XMM-Newton survey of the COSMOS field. XMM-Newton has detected ~800 X-ray sources down to limiting fluxes of ~5×10^{-16}, ~3×10^{-15}, and ~7×10^{-15} erg/cm2/s in the 0.5-2 keV, 2-10 keV and 5-10 keV bands, respectively. The work is complemented by an extensive collection of multi-wavelength data from 24 micron to UV, available from the COSMOS survey, for each of the X-ray sources, including spectroscopic redshifts for ~50% of the sample, and high-quality photometric redshifts for the rest. The XMM and multiwavelength flux limits are well matched: 1760 (98%) of the X-ray sources have optical counterparts, 1711 (~95%) have IRAC counterparts, and 1394 (~78%) have MIPS 24micron detections. Thanks to the redshift completeness (almost 100%) we were able to constrain the high-luminosity tail of the X-ray luminosity function confirming that the peak of the number density of logL_X>44.5 AGN is at z~2. Spectroscopically-identified obscured and unobscured AGN, as well as normal and starforming galaxies, present well-defined optical and infrared properties. We devised a robust method to identify a sample of ~150 high redshift (z>1), obscured AGN candidates for which optical spectroscopy is not available. We were able to determine that the fraction of the obscured AGN population at the highest (L_X>10^{44} erg s^{-1}) X-ray luminosity is ~15-30% when selection effects are taken into account, providing an important observational constraint for X-ray background synthesis. We studied in detail the optical spectrum and the overall spectral energy distribution of a prototypical Type 2 QSO, caught in a stage transitioning from being starburst dominated to AGN dominated, which was possible to isolate only thanks to the combination of X-ray and infrared observations.