Let $R$ be a prime ring with its Utumi ring of quotients $U$ and extended centroid $C$. Suppose that $F$ is a generalized derivation of $R$ and $L$ is a noncentral Lie ideal of $R$ such that $F(u)[F(u),u]^n=0$ for all $u \in L$, where $n\geq 1$ is a fixed integer. Then one of the following holds: \begin {itemize} \item [(1)] there exists $\lambda \in C$ such that $F(x)=\lambda x$ for all $x\in R$; \item [(2)] $R$ satisfies $s_4$ and $F(x)=ax+xb$ for all $x\in R$, with $a, b\in U$ and $a-b\in C$; \item [(3)] $\mathop {\rm char}(R)=2$ and $R$ satisfies $s_4$. \end {itemize} As an application we also obtain some range inclusion results of continuous generalized derivations on Banach algebras.