Gd2O3:1% Er3+, 18% Yb3+, x% Mg2+ (x = 0; 2.5; 4; 5; 6; 8;10; 20; 25; 50) and Gd2O3:1% Er3+, 18% Yb3+, 2,5% Mg2+, y% Li+ (y = 0.5–2.5) nanoparticles were synthesized by homogenous precipitation method and calcined at 900 °C for 3 h in air atmosphere. Powder x-ray diffraction, scanning electron microscopy, cathodoluminescence, transmission electron microscopy, energy dispersive x-ray spectroscopy and photoluminescence techniques were employed to characterize the obtained nanoparticles. We observed a 8-fold increase in red luminescence for samples suspended in DMSO solution for 2.5% of Mg2+ doping. The x-ray analysis shows that for the concentration of 2.5% Mg, the size of the crystallites in the NPs is the largest, which is mainly responsible for the increase in the intensity of the upconversion luminescence. But the addition of Li+ ions did not improve the luminescence of the upconversion due to decreasing of crystallites size of the NPs. Synthesized nanomaterials with very effective upconverting luminescence, can act as luminescent markers in in vivo imaging. The cytotoxicity of the nanoparticles was evaluated on the 4T1 cell line for the first time.