The entire quote (courtesy of Wikipedia)
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 encyclopedic 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. The abolition of religion as the illusory happiness of the people is the demand for their real happiness. To call on them to give up their illusions about their condition is to call on them to give up a condition that requires illusions. The criticism of religion is, therefore, in embryo, the criticism of that vale of tears of which religion is the halo.
So from my reading, Marx basically said that religion (at least in the 19th century) was a drug that helped ordinary folks cope with the pain of an awful world of exploitation. Rid the world of exploitation and you rid the world of the need for religion.
Like many things, I think over the last century and a half Marx has been taken out of context...both by the right (all you godless communists!) and by Stalinists and neo-Stalinists (rid yourselves of your stupid superstitions or else we'll lock you up in the gulag).
It's not so cut and dried. There are those who use religion as a tool of oppression and those who use it as a tool for liberation.
For example in Guatemala, as more and more Catholic clergy at the "base" level began converting to "liberation theology", the fascist generals began promoting the right-wing conservative Evangelical churches...even making one of them (General Ephraim Rios Mont) the president.
In El Salvador during the 1980's it was common to see right-wing death squad graffitti spray painted on buildings that said "Be a patriot. Kill a Priest".
Many of the folks involved in "Checkpoint Watch", the Israel-based organization that assists Palestinians with hassles at the checkpoints between the West Bank and Israel...are folks from the World Council of Churches.
So I think the real thing to look at is whether a religious organizations politics are progressive or reactionary and not to totally condemn all forms of religion as inherently reactionary.