We theoretically investigate the lift force on spherical nanoparticles in a shear flow of a dilute gas, wherein the non-rigid-body collision between the particle and the gas molecules is considered. The analytical formula of the lift force is derived based on the gas kinetic theory. In the limit of rigid-body collision, the formula is consistent with the theoretical results in the literature (Liu & Bogy, Phys. Fluids, vol. 20, 2008, 107102), which predicts that the lift force is in the opposite direction to the fluid velocity gradient (negative lift force). However, by taking into account gas–particle intermolecular interactions, the direction of the lift force on the nanoparticle is found to be dependent on temperature, i.e. both positive and negative lift forces exist in a certain temperature range. An explanation for the direction change of the lift force is given based on the analysis of the scattering angle under non-rigid-body particle–molecule collisions.