Let R be a ring with unity, g a generalized derivation on R and f(X 1,…,X k ) a multilinear polynomial. In this article we describe the structure of R provided that g(f(x 1,…,x k )) is either invertible or nilpotent for every x 1,…,x k in some nonzero ideal of R.