The literal meaning of varna was colour. From the Rigveda, we come to know that the earlier basis of division in society was colour. As we know the Aryan migrants were white-skinned people and they were conscious about their colour so they were maintaining a distinct identity against the black-skinned people. In some of the hymns of the Rigveda, it was declared that Aryans and Dasas (Slaves) were the two varnas and the saint Agastya was nourishing them.
But during the Rigvedic period itself, the division started even within the Aryan group with some scope for production surplus. A group of Aryans separated itself and made a claim for intellectual leadership of society. This group came to be known as the priest. Almost simultaneously another group of Aryans separated itself from the rest of the tribe and made a claim for the protection of society. This group was known as Rajanya. So Aryans were divided into there social groups- the priest, Rajanyas and the rest of the people. But still, the Rigvedic society was a more or less egalitarian society. There was not complete social stratification. The occupation was the basis of social division. With the change in occupation even varna status was going to be changed, for example- a Rajanya could get the status of a priest and vice versa. Saint Vishwamitra was a Rajanya by birth but he became a priest on the basis of his occupation. Likewise, the progeny of saint Bhirgu is given the credit to have founded a number of states. It means that the sons of saint Bhirgu got the status of a Rajanya. Even the common people (vis) could get the status of either a priest or a Rajanya on the basis of the change in their occupation.
But this situation gradually changed up to the Later Vedic period with the emergence of new varna, Shudra. For the first time, we come to know about four-fold varna system in the Purushsukta, which is the part of the Xth Mandala of the Rigveda. As it is supposed to be an interpolation so we can believe that the four-fold varna system started during the Later Vedic period in true sense. All four varnas Brahmins, Kshatriya, Vaishyas and Shudras were supposed to have evolved from the four organs of the primeval man. In this way, the varna system was given a ritual status. Up to the Later Vedic period, the social mobility of the Rigvedic period was definitely disrupted. Brahmins, Kshatriyas and Vaishyas were given the dvija status, separate from them there were Shudras. The duty of Shudras was to serve the upper three varnas. In this way, social stratification started during the Later Vedic period. It was during the Later Vedic period itself the concept of Gotra came into existence although Gotra-exogamous marriage became a reality during Buddha age.
Up to Buddha age, the tribal society of Vedic age was converted into a completely varna-divided society. With better scope for production surplus as the result of the expansion of the agrarian economy and urbanization, society was more and more stratified. Now birth became the basis of varna division. In order to maintain the purity of varna women were subordinated to men in society.