The Reissner–Nordström black hole solution in a generic cosmological constant background in the context of Rastall gravity is obtained. It is shown that the cosmological constant arises naturally from the consistency of the non-vacuum field equations of the Rastall theory for a spherical symmetric space–time, rather than its ad hoc introduction in the usual Einstein and Einstein–Maxwell field equations. The usual Reissner–Nordström, Schwarzschild, and Schwarzschild – (anti-)de Sitter black hole solutions in the framework of this theory are also addressed as the special independent subclasses of the obtained general solution.