We report the final optical identifications of the medium-depth (∼60 ks), contiguous (2 deg2) XMM-Newton survey of the COSMOS field. XMM-Newton has detected ∼1800 X-ray sources down to limiting fluxes of ∼5 × 10−16, ∼3 × 10−15, and ∼7 × 10−15 erg cm−2 s−1 in the 0.5–2 keV, 2–10 keV, and 5–10 keV bands, respectively (∼1 × 10−15, ∼6 × 10−15, and ∼1 × 10−14 erg cm−2 s−1, in the three bands, respectively, over 50% of the area). The work is complemented by an extensive collection of multiwavelength data from 24 μm 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 24 μm 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 log LX > 44.5 active galactic nuclei (AGNs) is at z ∼ 2. Spectroscopically identified obscured and unobscured AGNs, as well as normal and star-forming 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 (LX > 1044 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.