Sociologists define social class as a grouping of people who have approximately the same amount of power and prestige in a society. There are many ways to determine who gets to have power and prestige. Religion can be one of these ways. If religion is important enough in a society it is possible that class can be based more on religion than on any other factor.
That said, it is somewhat difficult to argue that religion was the most important determinant of class in Baghdad. The majority of people in Baghdad at this time were Muslim. It is not likely that all Muslims possessed a similar degree of power and prestige. This would be similar to saying that race was the greatest determinant of class in the pre-Civil War American South. It is true that all whites were above all blacks (as Muslims were above non-Muslims) but it is not true to say that all whites had similar amounts of power and prestige.
To the extent that religion really did influence class more than other factors, it is because religion was important in this society. This was a time when Islam was relatively new in the world and was struggling to expand its power. This would have made religion a more salient attribute than it was at other points in history.