Race and religion are similar in that they're invented belief structures that describe one's place in the world, especially in relation to an in-group and an out-group.
It's common to think of race as inherent and religion as voluntary, making them two different sorts of things. This understanding is especially true in societies with crusading and proselytizing religions, such as Christianity and Islam, where believers make a concerted effort to spread their beliefs to people of different races. For Jews, Samaritans, Hindus, Zoroastrians, and people of many other religions, however, the relationship between religion and race is apparent. And even in places where the relationship is not explicit, such as in the US, you can see parallels between the role of religion and the role of race.
Race and religion are both vehicles of tradition and community identity. In fact, tradition and community identity blur the line between race and religion. In the US, do we have Christmas trees because the country was settled by Northern Europeans or because it was settled by Christians? Answer: Yes.
Race and religion define insiders and outsiders. The terms "gaijin" and "gentile" are cousins just like race and religion are cousins. You might object that "gentile" is an ethnic term as much as a religious one, but "Gentile" is used to mean "non-Mormon" as well as "non-Jew." Considers: gaijin, gentile, heathen, pagan, infidel, foreigner, colored, kaffir, barbarian (non-Greek). Terms for "outsider" serve the same function whether they refer to race or to religion.
A "mixed marriage" can mean a marriage between people of different races or of different religions. Religion and race both define who one ought to marry, who counts as "one of us."
With both race and religion, who's in and who's out can be hard to define, and definitions are written up to adapt to political or economic conditions. In South Africa under apartheid, for example, Indians were categorized as Asians even though they're genetically similar to the Afrikaners. Meanwhile, the Japanese were given status as honorary whites, given their economic clout. As an example closer to home, who's a "Christian"? Are Catholics, Mormons, Southern Baptists, and Jehovah's Witnesses members of the same religion? Depends on who you ask. The boundaries for both race and religion are flexible because both systems are social inventions that people adapt to their local needs.
While the boundaries between races and religions are flexible, people take both categories terribly seriously. They believe in them as real phenomena with objective differences between one in-group (a race or religion) and the out-group (other races or religions). This sense that the lines between "races" and "religions" are hard lines is necessary for the legal, moral, economic, and social superiority that one group wants to have over others.
Race and religion are both put to use by the powers that be to maintain power over others. For example, US Southerners originally called their slaves "heathens" and resisted ministers' attempts to preach the Gospel to them. Slave owners thought it would be wrong to own fellow Christians and wanted to keep their slaves heathen. But the ministers assured the slaveholders that it was just fine for white Christians to enslave black Christians, and in return the slave owners let the ministers convert the slaves. Race stepped in to play the role the religion had played: to define who could own whom.
You hear about "the master race" and about "the one true religion." These two theories are basically the same idea: "we are good and they are bad." These two ideas are so closely related that they get tangled up together. For instance, the KKK and Christian Identity combine fire-and-brimstone Christianity with white supremacy. The Jewish concept of God's chosen people, combining race and religion, is so handy that it's been co-opted by numerous Christian groups, such as the British Israelites, the Mormons, and other Christian groups who see white Americans as the true descendents of the Hebrews.
Religion, obviously, does a lot more than define in-groups and out-groups. It's only in playing that role that religion is similar to race. But, historically and currently, that's a pretty big role.