Let R be a prime algebra over a commutative ring K, let I be a nonzero ideal of R and let f (X-1, ... , X-k) be a multilinear polynomial over K in k non-commuting indeterminates which is not centralvalued on R. Suppose that a is an element of R and d is a derivation of R such that a(d(f (x(1), ... , x(k)))(s) - gamma f (x(1), ... , x(k))(t))(m) is an element of Z(R) for all x(1), ... , x(k) is an element of I, where gamma is an element of K, s, t, m are fixed positive integers and Z(R) is the centre of R. It is shown that a = 0 or d = 0 except when R subset of M-2(F), the 2 x 2 matrix ring over a field F. This result gives a natural generalization of several well-known theorems in the literature. Moreover, with this we give an affirmative answer to the open conjecture recently raised by Huang in [Derivations with annihilator conditions on Lie ideals in prime rings. J Algebra Appl. 2020;19:2050025].