Opium of the people

The opium of the people (or opium of the masses) is a dictum used in reference to religion, derived from the most frequently paraphrased statements of German sociologist and economic theorist Karl Marx: "Religion is the opium of the people." In context, the statement is part of Marx's structural-functionalist argument that religion was constructed by people to calm uncertainty over their role in the universe and in society.
This statement was translated from the German original, "" and is often rendered as "religion…is the opiate of the "masses"." The full sentence from Marx translates (including italics) as: "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 quotation originates from the introduction of Marx's work "A Contribution to the Critique of Hegel's Philosophy of Right", which he started in 1843 but which was not published until after his death. The introduction to this work was published separately in 1844, in Marx's own journal "Deutsch–Französische Jahrbücher", a collaboration with Arnold Ruge. Often quoted only in part, the interpretation of the metaphor in its context has received much less attention.
Full quotation and history.
Marx wrote this passage in 1843 as part of the introduction to "Critique of Hegel's Philosophy of Right", a book that criticized philosopher Georg Wilhelm Friedrich Hegel's 1820 book, "Elements of the Philosophy of Right". This introduction was published in 1844 in a small journal called "Deutsch–Französische Jahrbücher"; however, the book itself was published posthumously.) As the journal had a print run of just 1,000 copies, it had no popular effect during the 19th century. The phrase became better known during the 1930s, when Marxism became more popular.
The quotation, in context, reads as follows (italics in original translation):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 [bold added].
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".
Metaphor.
Marx used the phrase to make a structural-functionalist argument about religion, and particularly about organized religion. 
In his view, religion may be false, but it is a function of something real. Specifically, Marx believed that religion had certain practical functions in society that were similar to the function of opium in a sick or injured person: it reduced people's immediate suffering and provided them with pleasant illusions which gave them the strength to carry on. In this sense, while Marx may have no sympathy for religion itself, he has deep sympathy for those proletariat who put their trust in it.
However, Marx also saw religion as harmful to revolutionary goals: by focusing on the eternal rather than the temporal, religion turns the attention of the oppressed away from the exploitation and class structure that encompasses their everyday lives. In the process, religion helps to foster a kind of false consciousness that emboldens cultural values and beliefs that support and validate the continued dominance of the ruling class. It thereby prevents the socialist revolution, the overthrowing of capitalism, and the establishment of a classless, socialist society.
In Marx’s view, once workers finally overthrow capitalism, unequal social relations will no longer need legitimating and people’s alienation will dissolve, along with any need for religion.
Similar statements and influence.
The same metaphor was used by many authors around the 19th century.
In 1798, Novalis wrote in "Blüthenstaub" ("Pollen"):
In 1840, Heinrich Heine also used the same analogy, in his essay on Ludwig Börne:
Welcome be a religion that pours into the bitter chalice of the suffering human species some sweet, soporific drops of spiritual opium, some drops of love, hope and faith.
Charles Kingsley, a canon of the Church of England, wrote the following in 1847, four years after Marx:
Miguel de Unamuno.
Miguel de Unamuno, the famed Spanish author of the Generation of '98, focused his nivola "San Manuel Bueno, mártir" around the theme of religion's opiatic effect on the people of rural Spain. In the book, the protagonist Don Manuel is a priest who does not believe in God, but continues preaching because he sees the positive impact he can make in the lives of his parishioners. Religion in this way also serves to cure his own deep depression, through the happiness he feels from helping the people of Valverde de Lucerna. Unamuno makes direct reference to Marx when Don Manuel explains:
Lenin.
Vladimir Lenin, speaking of religion in "Novaya Zhizn" in 1905, alluded to Marx's earlier comments:
Those who toil and live in want all their lives are taught by religion to be submissive and patient while here on earth, and to take comfort in the hope of a heavenly reward. But those who live by the labour of others are taught by religion to practise charity while on earth, thus offering them a very cheap way of justifying their entire existence as exploiters and selling them at a moderate price tickets to well-being in heaven. Religion is opium for the people []. Religion is a sort of spiritual booze, in which the slaves of capital drown their human image [], their demand for a life more or less worthy of man. (emphasis added).
Modern comparisons.
Some writers make a modern comparison of the phrase "opium of the people" to that akin to sports fandom, celebrities, the distractions of television, the internet, and other entertainment, etc. This can be seen as a parallel to the concept of bread and circuses.