ABSTRACT Yttrium (Y), a key s-process element, is commonly used in nucleosynthesis studies and as a Galactic chemical clock when combined with magnesium (Mg). We study the applicability of the previously assumed local thermal equilibrium (LTE) line formation assumption in Y abundance studies of main-sequence and red giant stars, and probe the impact of NLTE (non-LTE) effects on the [Y/Mg] ratio, a proposed stellar age indicator. We derive stellar parameters, ages, and NLTE abundances of Fe, Mg, and Y for 48 solar analogue stars from high-resolution spectra acquired within the Gaia-ESO survey. For Y, we present a new NLTE atomic model. We determine a solar NLTE abundance of A(Y)NLTE = 2.12 ± 0.04 dex, 0.04 dex higher than LTE. NLTE effects on Y abundance are modest for optical Y ii lines, which are frequently used in Sun-like stars diagnostics. NLTE has a small impact on the [Y/Mg] ratio in such stars. For metal-poor red giants, NLTE effects on Y ii lines are substantial, potentially exceeding +0.5 dex. For the Gaia/4MOST/WEAVE benchmark star, HD 122563, we find the NLTE abundance ratio of [Y/Fe]NLTE = −0.55 ± 0.04 dex with consistent abundances obtained from different Y ii lines. NLTE has a differential effect on Y abundance diagnostics in late-type stars. They notably affect Y ii lines in red giants and very metal-poor stars, which are typical Galactic enrichment tracers of neutron-capture elements. For main-sequence stars, NLTE effects on optical diagnostic Y ii lines remain minimal across metallicities. This affirms the [Y/Mg] ratio’s reliability as a cosmochronometer for Sun-like stars.