In "The Premises of the Materialist Method" from Marx's The German Ideology, he writes that "the first premise of all human history is, of course, the existence of living human individuals." He goes on to write, "Men can be distinguished from animals by consciousness, by religion, or anything else you like." This consciousness emerges individually and collectively. It emerges when people start to produce the means of their own survival. They are not just producing their physical means of survival (food, shelter, etc.); they are also producing their mental modes of life. This translates into who they are and what they will become. So, for Marx, how and what people produce will determine who they will become. This is why he says that consciousness comes from the material conditions of history. In short, the stuff we do informs who we become.
That which a group or nation produces becomes a basis for its economy. That economy creates a division of labor. Such economic and political divisions lead to the structure of classes. Marx goes into an explanation of the history of economic structures and these include tribal ownership, state ownership, feudalism, and finally private property and capitalism. Within each historical stage, consciousness emerges because people interact with each other. Marx says that language and consciousness are similar in this way. Both emerge out of the necessity of interaction. And this interaction is based on production of the means of living. When the division of labor starts to include mental as well as physical labor, consciousness then branches out to include things like philosophy, religion, and so on. And even when a philosophical outlook contradicts or challenges the way society is structured, Marx says that this contradiction arises out of contradictions in the social structure. In other words, consciousness and ways of thinking always come from the ways we live: social, economic, and political. The actual physical and material things we do are the sole basis for how consciousness develops.
Marx also says that if a class is being oppressed, their only hope of coming out of that oppression is to achieve class consciousness. This means that the individual and the group must become "conscious" of their place in history. In other words, they must become conscious of the way society has determined their consciousness. Before a class has this awakening, they are in what Marx calls a "false consciousness." Under false consciousness, individuals and/or societies are unaware of how the state and social structures have determined their way of life and even how they think about themselves. Some states even purposefully mislead the lower classes to keep them under false consciousness. This makes it easier for the state or owning class (upper class with all the money) to keep the lower classes in a subservient position. But when those individuals and societies become aware of how state and social structures have determined their physical and mental lives, then they break out of the false consciousness. This is the first step to liberation.
So, the development begins with human beings. It becomes efficient with people interacting. This interaction is based upon production and economy. This leads to organization and with that organization, structures are formed. The structures determine classes and how those classes think about their place in history. A class can liberate itself if it becomes aware of how its consciousness has been determined by historical materialism. They do so by becoming conscious of how their consciousness was constructed in the first place.