A series of new multifunctional nanomesoporous materials based on upconversion nanophosphors NaYF4:Yb,Tm@NaGdF4 (UCNPs) and lanthanide complexes were designed and synthesized through mesoporous capping UCNPs nanophosphors and linking lanthanide (Ln) complexes. The obtained UCNPs@mSiO2-Ln(dbm)4 (Ln = Eu, Sm, Er, Nd, Yb) materials can achieve downconversion and upconversion luminescence to show multicolor emission (covering the spectral region from 450 nm to 1700 nm) under visible-light excitation and 980 nm excitation, respectively. In addition, low cytotoxicity and good biocompatibility was found as determined by methyl thiazolyl tetrazolium assay, and the nanomesoporous materials were successfully applied to cell imaging in vitro based on Eu(3+) luminescence (under 405 nm excitation) and small animal imaging based on Tm(3+) luminescence (under 980 nm excitation). The doped Gd(3+) ion endows the nanomesoporous materials UCNPs@mSiO2-Ln(dbm)4 with effective T1 signal enhancement, which affords them as potential magnetic resonance imaging (MRI) contrast agents. Therefore, our results may provide more exciting opportunities for multimodal bioimaging and multifunctional applications.