In The German Ideology (1846) Marx and Engels elaborated their ideas on the materialist approach to history and, in a sharp polemic, settled accounts with the idealist philosophy of the Young Hegelians. The full text can be found at www.marxists.org.
The ideas of the ruling class are in every epoch the ruling ideas, i.e. the class which is the ruling material force of society, is at the same time its ruling intellectual force. The class which has the means of material production at its disposal, has control at the same time over the means of mental production, so that thereby, generally speaking, the ideas of those who lack the means of mental production are subject to it. The ruling ideas are nothing more than the ideal expression of the dominant material relationships, the dominant material relationships grasped as ideas; hence of the relationships which make the one class the ruling one, therefore, the ideas of its dominance. The individuals composing the ruling class possess among other things consciousness, and therefore think. Insofar, therefore, as they rule as a class and determine the extent and compass of an epoch, it is self-evident that they do this in its whole range, hence among other things rule also as thinkers, as producers of ideas, and regulate the production and distribution of the ideas of their age: thus their ideas are the ruling ideas of the epoch. For instance, in an age and in a country where royal power, aristocracy, and bourgeoisie are contending for mastery and where, therefore, mastery is shared, the doctrine of the separation of powers proves to be the dominant idea and is expressed as an “eternal law.”