Context. Intermediate-mass, chemically peculiar stars with strong magnetic fields provide an excellent opportunity to study the topology of their surface magnetic fields and the interplay between magnetic geometries and abundance inhomogeneities in the atmospheres of these stars. Aims. We reconstruct detailed maps of the surface magnetic field and abundance distributions for the magnetic Ap star HD 125248. Methods. We performed the analysis based on phase-resolved, four Stokes parameter spectropolarimetric observations obtained with the HARPSpol instrument. These data were interpreted with the help of magnetic Doppler imaging techniques and model atmospheres taking the effects of strong magnetic fields and nonsolar chemical composition into account. Results. We improved the atmospheric parameters of the star, T eff = 9850 ± 250 K and log g = 4.05 ± 0.10. We performed detailed abundance analysis, which confirmed that HD 125248 has abundances typical of other Ap stars, and discovered significant vertical stratification effects for the Fe ii and Cr ii ions. We computed LSD Stokes profiles using several line masks corresponding to Fepeak and rare earth elements, and studied their behavior with rotational phase. Combining previous longitudinal field measurements with our own observations, we improved the rotational period of the star P rot = 9.29558 ± 0.00006 d. Magnetic Doppler imaging of HD 125248 showed that its magnetic field is mostly poloidal and quasi-dipolar with two large spots of different polarity and field strength. The chemical maps of Fe, Cr, Ce, Nd, Gd, and Ti show abundance contrasts of 0.9-3.5 dex. Among these elements, the Fe abundance map does not show high-contrast features. Cr is overabundant around the negative magnetic pole and has 3.5 dex abundance range. The rare earth elements and Ti are overabundant near the positive magnetic pole. Conclusions. The magnetic field of HD 125248 has strong deviations from the classical oblique dipole field geometry. A comparison of the magnetic field topology of HD 125248 with the results derived for other stars using four Stokes magnetic Doppler imaging suggests evidence that the field topology becomes simpler with increasing age. The abundance maps show weak correlation with magnetic field geometry, but they do not agree with the theoretical atomic diffusion calculations, which predict element accumulation in the horizontal field regions.