Spain's conservative and far-right parties secured a convincing victory in a snap election, ending Pedro Sanchez's eight-year tenure.