Context. The diffuse interstellar medium (ISM) is an integral part of the evolution of the entire Galaxy. Metals are produced by stars and their abundances are the direct testimony of the history of stellar evolution. However, the interstellar dust composition is not well known and the total abundances are yet to be accurately determined. Aims. We probe ISM dust composition, total abundances, and abundance gradients through the study of interstellar absorption features in the high-resolution X-ray spectra of Galactic low-mass X-ray binaries (LMXBs). Methods. We used high-quality grating spectra of nine LMXBs taken with XMM-Newton. We measured the column densities of O, Ne, Mg, and Fe with an empirical model and estimated the Galactic abundance gradients. Results. The column densities of the neutral gas species are in agreement with those found in the literature. Solids are a significant reservoir of metals like oxygen and iron. Respectively, 15-25% and 65-90% of the total amount of O i and Fe i is found in dust.The dust amount and mixture seem to be consistent along all the lines-of-sight (LOS). Our estimates of abundance gradients and predictions of local interstellar abundances are in agreement with those measured at longer wavelengths. Conclusions. Our work shows that X-ray spectroscopy is a very powerful method to probe the ISM. For instance, on a large scale the ISM appears to be chemically homogeneous showing similar gas ionization ratios and dust mixtures. The agreement between the abundances of the ISM and the stellar objects suggests that the local Galaxy is also chemically homogeneous.