We find necessary and sufficient conditions for a spectral differential equation [GRAPHICS] to have Sobolev orthogonal polynomials of solutions, which are orthogonal relative to the Sobolev (pseudo-) inner product [GRAPHICS] where d mu and d nu are signed Borel measures having finite moments. This result generalizes a result by H. L. Krall, which handles the case when d nu = 0.