I've always assumed that when Marx said "Religion is the opium of the masses", he meant that religion is a tool used by the ruling classes of the time to dominate the lower classes. But when reading the full original quote:
The foundation of irreligious criticism is: Man makes religion, religion does not make man. Religion is, indeed, the self-consciousness and self-esteem of man who has either not yet won through to himself, or has already lost himself again. But man is no abstract being squatting outside the world. Man is the world of man – state, society. This state and this society produce religion, which is an inverted consciousness of the world, because they are an inverted world. Religion is the general theory of this world, its encyclopaedic compendium, its logic in popular form, its spiritual point d’honneur, its enthusiasm, its moral sanction, its solemn complement, and its universal basis of consolation and justification. It is the fantastic realization of the human essence since the human essence has not acquired any true reality. The struggle against religion is, therefore, indirectly the struggle against that world whose spiritual aroma is religion.
Religious suffering is, at one and the same time, the expression of real suffering and a protest against real suffering. Religion is the sigh of the oppressed creature, the heart of a heartless world, and the soul of soulless conditions. It is the opium of the people. -- Contribution to the Critique of Hegel's Philosophy of Right, 1843.
I am a little confused. On one hand, he states that "This state and this society produce religion", which seems to confirm my original interpretation that religion is a tool of oppression used by the upper class.
On the other hand, he later says "Religious suffering is, at one and the same time, the expression of real suffering and a protest against real suffering. Religion is the sigh of the oppressed creature, the heart of a heartless world, and the soul of soulless conditions.", which I read as saying that religion is a reaction by the masses to the oppression brought on them by the ruling class, not a tool of the the ruling class itself. To extend the drug analogy of the famous part of the quote, the masses are self medicating on the religious opium, it is not being forced on them by their overlords.
So which view is correct according to Marx: Is religion a self-administered reaction to oppression? or is it a tool of domination administered by the ruling class?