Context. The nature of the hard X-ray source XSS J12270-4859 is still unclear. It was claimed to be a possible magnetic cataclysmic variable of the Intermediate Polar type from its optical spectrum and a possible 860 s X-ray periodicity in RXTE data. However, recent observations do not support the latter variability, leaving this X-ray source still unclassified. Aims. To investigate its nature we present a broad-band X-ray and gamma ray study of this source based on a recent XMM-Newton observation and archival INTEGRAL and RXTE data. Using the Fermi/LAT 1-year point source catalogue, we tentatively associate XSS J12270-4859 with 1FGL J1227.9-4852, a source of high-energy gamma rays with emission up to 10 GeV. We further complement the study with UV photometry from XMM-Newton and ground-based optical and near-IR photometry. Methods. We have analysed both timing and spectral properties in the gamma rays, X-rays, UV and optical/near-IR bands of XSS J12270-4859. Results. The X-ray emission is highly variable, showing flares and intensity dips. The flares consist of flare-dip pairs. Flares are detected in both X-rays and the UV range, while the subsequent dips are present only in the X-ray band. Further aperiodic dipping behaviour is observed during X-ray quiescence, but not in the UV. The broad-band 0.2-100 keV X-ray/soft gamma ray spectrum is featureless and well described by a power law model with Γ = 1.7. The high-energy spectrum from 100 MeV to 10 GeV is represented by a power law index of 2.45. The luminosity ratio between 0.1-100 GeV and 0.2-100 keV is ∼0.8, indicating that the GeV emission is a significant component of the total energy output. Furthermore, the X-ray spectrum does not greatly change during flares, quiescence and the dips seen in quiescence. The X-ray spectrum however hardens during the post-flare dips, where a partial covering absorber is also required to fit the spectrum. Optical photometry acquired at different epochs reveals a period of 4.32 hr that could be ascribed to the binary orbital period. Near-IR, possibly ellipsoidal, variations are detected. Large amplitude variability on shorter (tens mins) timescales is found to be non-periodic. Conclusions. The observed variability at all wavelengths together with the spectral characteristics strongly favour a low-mass atypical low-luminosity X-ray binary and are against a magnetic cataclysmic variable nature. The association with a Fermi/LAT high-energy gamma ray source further strengths this interpretation.