Fluorescent nanosensors hold the potential to revolutionize life sciences and medicine. However, their adaptation and translation into the in vivo environment is fundamentally hampered by unfavourable tissue scattering and intrinsic autofluorescence. Here we develop wavelength-induced frequency filtering (WIFF) whereby the fluorescence excitation wavelength is modulated across the absorption peak of a nanosensor, allowing the emission signal to be separated from the autofluorescence background, increasing the desired signal relative to noise, and internally referencing it to protect against artefacts. Using highly scattering phantom tissues, an SKH1-E mouse model and other complex tissue types, we show that WIFF improves the nanosensor signal-to-noise ratio across the visible and near-infrared spectra up to 52-fold. This improvement enables the ability to track fluorescent carbon nanotube sensor responses to riboflavin, ascorbic acid, hydrogen peroxide and a chemotherapeutic drug metabolite for depths up to 5.5 ± 0.1 cm when excited at 730 nm and emitting between 1,100 and 1,300 nm, even allowing the monitoring of riboflavin diffusion in thick tissue. As an application, nanosensors aided by WIFF detect the chemotherapeutic activity of temozolomide transcranially at 2.4 ± 0.1 cm through the porcine brain without the use of fibre optic or cranial window insertion. The ability of nanosensors to monitor previously inaccessible in vivo environments will be important for life-sciences research, therapeutics and medical diagnostics.