This paper studies the long-time dynamics of classical solutions to an initial-boundary value problem for the 2D Navier–Stokes equations of an incompressible and inhomogeneous fluid flow: \(\begin{aligned} \begin{aligned} \rho _t+\textbf{u}\cdot \nabla \rho&=0,&\textbf{x}&\in \Omega ,\ t>0,\\ \rho \textbf{u}_t+\rho \textbf{u}\cdot \nabla \textbf{u}+ \nabla P&=\mu \Delta \textbf{u}+\rho \nabla \psi ,&\textbf{x}&\in \Omega ,\ t>0,\\ \nabla \cdot \textbf{u}&=0,&\textbf{x}&\in \Omega ,\ t>0, \end{aligned} \end{aligned}\) where \(\Omega = (0,L)\times (0,H)\) is a rectangle. The system of equations is supplemented with time-dependent boundary condition of Couette type for the velocity field: \(\textbf{u}|_{\partial \Omega }=(\alpha (t)x_2,0)^\textrm{T} \equiv \widehat{\textbf{u}}(t)\) , where \(\alpha \) is a smooth function of t, and periodic boundary condition for \(\rho \) and \(\psi \) on two vertical sides of \(\Omega \) . Under certain regularity conditions for \(\psi \) and \(\alpha \) , it is shown that for given generic initial data in \(H^3(\Omega \) ), there exists a unique solution to the initial-boundary value problem and the perturbation \((\textbf{u}-\widehat{\textbf{u}})(\textbf{x},t)\) converges to zero in certain topology as time goes to infinity.