808 nm excited upconversion nanoparticles (UCNPs) have received extensive attention in the biomedical areas. However, one of the limitations of UCNPs is their lower luminescence efficiency. Aimed at this problem, a series of BaGdF5-based UCNPs were prepared by a layer-by-layer procedure. And UC luminescence properties are optimized by varying the doping concentration of rare earth ions, amount and types of shells. It is found that if the amount of core BaGdF5:20%Yb3+/2%Er3+ was fixed at 0.5 mmol, the optimized conditions of three shell layers are 0.3 mmol of BaGdF5:10%Yb3+, 0.5 mmol of BaNdF5 and 0.5 mmol of BaGdF5. Thus the UC luminescence intensity of the resultant nanoparticles BaGdF5:20%Yb3+/2%Er3+@BaGdF5:10%Yb3+@BaNdF5@BaGdF5 (Er@Yb@Nd@Gd) is enhanced more than four times compared with that of BaGdF5:20%Yb3+/2%Er3+@BaGdF5:10%Yb3+@BaNdF5 (Er@Yb@Nd). To further improve the biocompatibility and applications in the biological field, carboxymethyl chitosan (CMC), a type of biocompatible water-transfer agent, was used as a capping ligand to modify the surface of Er@Yb@Nd@Gd. An antitumor drug doxorubicin (DOX) was loaded to the CMC-modified Er@Yb@Nd@Gd nanocarriers by electrostatic interactions. The DOX can be selectively released in an acidic environment, which shows a pH-triggered drug release behavior. On the other hand, Er@Yb@Nd@Gd nanoparticles have excellent magnetic properties due to the presence of Gd components. T1-weighted magnetic resonance imaging (MRI) reveals the concentration-dependent brightening effect with longitudinal relaxivity (r1) as high as 43.77 s-1 (mM)-1, much higher than that of previous Gd3+-based counterparts. The results indicate that this multifunctional drug delivery system is expected to be a promising platform for simultaneous cancer therapy and bioimaging.