  Aims We study the effects of non-local thermodynamic equilibrium (NLTE) on
the determination of stellar parameters and abundances of Fe, Mg, and Ti from
the medium-resolution spectra of FGK stars.} Methods We extend the Payne
fitting approach to draw on NLTE and LTE spectral models. These are used to
analyse the spectra of the Gaia-ESO benchmark stars and the spectra of 742
stars in 13 open and globular clusters in the Milky Way: NGC 3532, NGC 5927,
NGC 2243, NGC 104, NGC 1851, NGC 2808, NGC 362, M 2, MGC 6752, NGC 1904, NGC
4833, NGC 4372 and M 15. Results Our approach accurately recovers effective
temperatures, surface gravities, and abundances of the benchmark stars and
clusters members. The differences between NLTE and LTE are significant in the
metal-poor regime, [Fe/H] $\lesssim -1$. The NLTE [Fe/H] values are
systematically higher, whereas the average NLTE [Mg/Fe] abundance ratios are
$\sim 0.15$ dex lower, compared to LTE. Our LTE measurements of metallicities
and abundances of stars in Galactic clusters are in a good agreement with the
literature. Yet, for most clusters, our study yields the first estimates of
NLTE abundances of Fe, Mg and Ti. Conclusions All clusters investigated in this
work are homogeneous in Fe and Ti, with the intra-cluster abundance variations
of less than 0.04 dex. NGC 2808, NGC 4833, M 2 and M 15 show significant
dispersions in [Mg/Fe]. Contrary to common assumptions, the NLTE analysis
changes the mean abundance ratios in the clusters, but it does not influence
the intra-cluster abundance dispersions.
