Deep tissue imaging in the second near-infrared (NIR-II) window holds great promise for physiological studies and biomedical applications. However, inhomogeneous signal attenuation in biological matter hampers the application of multiple-wavelength NIR-II probes to multiplexed imaging. Here, we present lanthanide-doped NIR-II nanoparticles with engineered luminescence lifetimes for in vivo quantitative imaging using time-domain multiplexing. To achieve this, we have devised a systematic approach based on controlled energy relay that creates a tunable lifetime range spanning three orders of magnitude with a single emission band. We consistently resolve selected lifetimes from the NIR-II nanoparticle probes at depths of up to 8 mm in biological tissues, where the signal-to-noise ratio derived from intensity measurements drops below 1.5. We demonstrate that robust lifetime coding is independent of tissue penetration depth, and we apply in vivo multiplexing to identify tumour subtypes in living mice. Our results correlate well with standard ex vivo immunohistochemistry assays, suggesting that luminescence lifetime imaging could be used as a minimally invasive approach for disease diagnosis.