  We show that properly and cocompactly cubulated relatively hyperbolic groups
are virtually special, provided the peripheral subgroups are virtually special
in a way that is compatible with the cubulation. This extends Agol's result for
cubulated hyperbolic groups, and applies to a wide range of peripheral
subgroups. In particular, we deduce virtual specialness for properly and
cocompactly cubulated groups that are hyperbolic relative to virtually abelian
groups. As another consequence, by using a theorem of Martin and Steenbock we
obtain virtual specialness for groups obtained as a quotient of a free product
of finitely many virtually compact special groups by a finite set of relators
satisfying the classical $C'(1/6)$-small cancellation condition.
