Spanish Prime Minister Mariano Rajoy has been voted out of office by parliament in a vote of no confidence.