Marx understood ideology as the ideas and beliefs that existed within a society. These included religion, political beliefs, social mores, and other things that we might also call a "worldview." Some other philosophers, especially the so-called "German idealists," had stressed the power of ideas like these in history. Marx believed ideology was important, but he described it as "superstructure." What he meant by this is that ideology was produced by a ruling class—in the industrial era the bourgeoisie—and its purpose was to maintain the social conditions that existed in the society. In other words, ideology could only really correctly be seen in relation to the economic forces in a society—the means of production.
Ideology doesn't change the world, according to Marx; it reflects it and perpetuates the conditions that created it. Marx famously wrote that religion was "the opiate of the people," and what he meant was that it was essentially superstructural. Religion was a way to tame working class people and justify the relationship between the bourgeoisie and the proletariat. This was one of Marx's most important insights for modern scholars. Even historians, sociologists, and other scholars who do not espouse Marx's revolutionary politics and who regard his notion of ideology to be reductionist still attempt to examine the relationship between ideas and economic and social realities.