Racism grew from religism
Historically, antisemitism and afrophobia are both older than racism. It was these two targeting foci of categorism that gave birth to the categorization focus known as racism, not the other way around. Instead, they both started as forms of religism.
Antisemitism was first based on the idea that unconverted Jews were responsible for killing Jesus Christ, while afrophobia was based on the idea that Africans were pagans. The idea that they were descended from Noah's son Ham (who was cursed by God) came later, but before the concept of race developed.
Antisemitism goes back to the early days of Christianity, back when most Christians were born as Jews but converted to Christianity as adults. During the first millennium or so, it was taken for granted that Jews stopped being Jews when they converted. And that hatred against Jews should thus not extend to former Jews who had converted to Christianity.
Afrophobia started much later, as a side effect of Christians gradually developing a taboo against using other Christians as slaves. Since they still wanted to use slave labor, they restricted themselves to using pagans as slaves. While most Africans were pagans and thus acceptable to use as slaves, Christian Africans were shielded from slavery in the same way as European Christians.
In both cases, the excuses for discrimination and bigotry gradually shifted from targeting he victim's faith to targeting the victim's blood.
In the case of antisemitism, this process started in Spain in the 1500:th century, with the doctrine of pure blood. By this doctrine, it was no longer enough to believe in the Christian faith to be a real Christian. You also needed to have Pure Christian Blood, which meant that all of your forefathers were Christians - or at least not Jews. When this doctrine arose, converted former Jews were already being persecuted in Spain – suspected of secretly still believing in Judaism. With ideas of “once a Jew, always a Jew” already being popular, adding blood mysticism to the mix was simply one more way to justify it.
In the case of afrophobia, the American slave trade originally only allowed for pagans to be used as slaves. As the African slaves brought to America started to convert to Christianity, the rule was extended to the descendants of pagans. The excuse that Africans were descended from Ham was used to justify keeping non-White Christians as slaves. While this argument had previously been used by Christians and Muslims alike to justify enslavement of various ethnic groups (in no way limited to Africans), this was when it became mainstream in post-medieval western culture.
From these roots, antisemitism and afrophobia gradually developed into the great racist ideologies of modern western civilization.
Note: This page is based on “Racism. A short history” by George M. Fredrickson. Published in 2002 by Princeton University Press, USA. Reference included here because it is not included in the thesis.