My Spanish ancestors developed the concept of “Purity of Blood” as a way of excluding Jewish- and Muslim-descended people from the benefits of high social class. It is rooted in Medieval antisemitism and anti-Islamism https://dornsife.usc.edu/news/stories/659/tracing-the-roots-of-discrimination/
In colonial times, “purity of blood” morphed into an obsession with lightness of skin, and the Spanish developed an elaborate hierarchy based on skin color and ancestry, called the “castas” system.