This is part of an article I wrote for the old Marxistpedia site:
Marx did not provide a simple definition of class. He used the term loosely, often as a substitute for "faction", "group", or "layer". In one text Marx even uses the terms "ruling class" and "ruling faction" interchangeably. In the Manifesto he speaks of class as "various orders", "social ranks", and even the broad category of "oppressor and oppressed". But Marx's use of the term did imply a certain relationship between specific classes and society as a whole. For example, in Capital vol.3 Marx defines the "three big classes of modern society" in terms of ownership: the owners of labour power, the owners of capital, and land-owners. Unfortunately, Marx's analysis of why these three groups constituted distinct classes was never completed before his death. Definitions of class based on ownership would predominate in the 20th century.
Marx's concept of class was deeply tied to his theory of history and human society. In a 1852 letter, Marx wrote:
Now as for myself, I do not claim to have discovered either the existence of classes in modern society or the struggle between them. Long before me, bourgeois historians had described the historical development of this struggle between the classes, as had bourgeois economists their economic anatomy. My own contribution was 1. to show that the existence of classes is merely bound up with certain historical phases in the development of production; 2. that the class struggle necessarily leads to the dictatorship of the proletariat; 3. that this dictatorship itself constitutes no more than a transition to the abolition of all classes and to a classless society.
In Wage Labour and Capital, Marx describes the growth of social relations, and thus classes, out of material production:
"In the process of production, human beings work not only upon nature, but also upon one another. They produce only by working together in a specified manner and reciprocally exchanging their activities. In order to produce, they enter into definite connections and relations to one another, and only within these social connections and relations does their influence upon nature operate – i.e., does production take place."
In Capital vol.3, Marx wrote:
"The specific economic form, in which unpaid surplus-labour is pumped out of direct producers, determines the relationship of rulers and ruled, as it grows directly out of production itself and, in turn, reacts upon it as a determining element. Upon this, however, is founded the entire formation of the economic community which grows up out of the production relations themselves, thereby simultaneously its specific political form. It is always the direct relationship of the owners of the conditions of production to the direct producers — a relation always naturally corresponding to a definite stage in the development of the methods of labour and thereby its social productivity — which reveals the innermost secret, the hidden basis of the entire social structure and with it the political form of the relation of sovereignty and dependence, in short, the corresponding specific form of the state."