Aims. We investigate the impact of realistic three-dimensional (3D) hydrodynamical model atmospheres of red giant stars at different metallicities on the formation of spectral lines of a number of ions and molecules. Methods. We carry out realistic, ab initio, 3D, hydrodynamical simulations of surface convection at the surface of red giant stars with varying effective temperatures and metallicities. We use the convection simulations as time-dependent hydrodynamical model stellar atmospheres to calculate spectral lines for a number of atomic (Li , O , Na , Mg , Ca , Fe , and Fe ) and molecular (CH, NH, and OH) lines under the assumption of local thermodynamic equilibrium (LTE). We carry out a differential comparison of the line strengths computed in 3D with the results of analogous line formation calculations for classical, 1D, hydrostatic, plane-parallel model atmospheres in order to estimate the impact of 3D models on the derivation of elemental abundances. Results. The temperature and density inhomogeneities and correlated velocity fields in 3D models, as well as the differences between the mean 3D stratifications and corresponding 1D model atmospheres significantly affect the predicted strengths of spectral lines. Under the assumption of LTE, the low atmospheric temperatures encountered in 3D model atmospheres of very metal-poor giant stars cause spectral lines from neutral species and molecules to appear stronger than within the framework of 1D models. As a consequence, elemental abundances derived from these lines using 3D models are significantly lower than according to 1D analyses. In particular, the differences between 3D and 1D abundances of C, N, and O derived from CH, NH, and OH weak low-excitation lines are found to be in the range −0.5 dex to −1.0 dex for the the red giant stars at [Fe/H] = −3 considered here. At this metallicity, large negative corrections (about −0.8 dex) are also found, in LTE, for weak low-excitation Fe lines. We caution, however, that the neglected departures from LTE might be significant for these and other elements and comparable to the effects due to stellar granulation.