The caste system as we know it has been around for around 1,500 years. The rigid adherence to caste system and prohibition of inter caste marriages was finalized during the period of Later Guptas i.e in the 6th Century CE.
This rigidity was enforced on the basis of a Sanskrit Scripture called "Manu Smriti" (Laws of Manu). from the usage of language this book appears to be written around 150 to 50 BCE or 2100 years ago.
The oldest available written scripture of Hinduism is Rig Veda written about 1500 to 1200 BCE or 3250 years ago. The writings are based on oral traditions handed down from about 3000 BCE or more than 5000 years old.
According to the Rig Veda, progenitors of the four ranked varna groups sprang from various parts of the body of the primordial man, which Brahma created from clay. Each group had a function in sustaining the life of society-the social body. Brahmans, or priests, were created from the mouth. They were to provide for the intellectual and spiritual needs of the community. Kshatriyas, warriors and rulers, were derived from the arms. Their role was to rule and to protect others. Vaishyas-landowners and merchants--sprang from the thighs, and were entrusted with the care of commerce and agriculture. Shudras-artisans and servants-came from the feet. Their task was to perform all manual labor.
There was no restriction on inter mingling or on inter-caste marriages. The varna of the person was decided by their gunas - characterisitics and ability. No one was a Brahmin, Kshatriya, Vaisya or Sudra by birth. His skills determined his varna.
Caste on the basis of birth and prohibition of Inter caste marriage is an abhorrence that was brought about 1500 years ago in the 5000 year old tradition.