Weighted Rota–Baxter operators on associative algebras are closely related to modified Yang–Baxter equations, splitting of algebras, and weighted infinitesimal bialgebras and play an important role in mathematical physics. For any λ ∈ k, we construct a differential graded Lie algebra whose Maurer–Cartan elements are given by λ-weighted relative Rota–Baxter operators. Using such characterization, we define the cohomology of a λ-weighted relative Rota-Baxter operator T and interpret this as the Hochschild cohomology of a suitable algebra with coefficients in an appropriate bimodule. We study linear, formal, and finite order deformations of T from cohomological points of view. Among others, we introduce Nijenhuis elements that generate trivial linear deformations and define a second cohomology class to any finite order deformation, which is the obstruction to extend the deformation. In the end, we also consider the cohomology of λ-weighted relative Rota–Baxter operators in the Lie case and find a connection with the case of associative algebras.