The Martian satellite Phobos has been observed on 2007 February 24 and 25, during the pre- and post-Mars closest approach (CA) of the ESA Rosetta spacecraft Mars swing-by. The goal of the observations was the determination of the surface composition of different areas of Phobos, in order to obtain new clues regarding its nature and origin. Near-ultraviolet, visible and near-infrared (263.5–992.0 nm) images of Phobos's surface were acquired using the Narrow Angle Camera of the OSIRIS instrument onboard Rosetta. The six multi-wavelength sets of observations allowed a spectrophotometric characterization of different areas of the satellite, belonging respectively to the leading and trailing hemisphere of the anti-Mars hemisphere, and also of a section of its sub-Mars hemisphere. The pre-CA spectrophotometric data obtained with a phase angle of 19° have a spectral trend consistent within the error bars with those of unresolved/disc-integrated measurements present in the literature. In addition, we detect an absorption band centred at 950 nm, which is consistent with the presence of pyroxene. The post-CA observations cover from NUV to NIR a portion of the surface (0° to 43°E of longitude) never studied before. The reflectance measured on our data does not fit with the previous spectrophotometry above 650 nm. This difference can be due to two reasons. First, the OSIRIS observed area in this observation phase is completely different with respect to the other local specific spectra and hence the spectrum may be different. Secondly, due to the totally different observation geometry (the phase angle ranges from 137° to 140°), the differences of spectral slope can be due to phase reddening. The comparison of our reflectance spectra, both pre- and post-CA, with those of D-type asteroids shows that the spectra of Phobos are all redder than the mean D-type spectrum, but within the spectral dispersion of other D-types. To complement this result, we performed an investigation of the conditions needed to collisionally capture Phobos in a way similar to that proposed for the irregular satellites of the giant planets. Once put in the context of the current understanding of the evolution of the early Solar system, the coupled observational and dynamical results we obtained strongly argue for an early capture of Phobos, likely immediately after the formation of Mars.