Sanskrit is an Indo-European language. They are all descended from a most recent common ancestor called Proto-Indo-European, which is thought to have been spoken in the late Neolithic by nomadic horse peoples of the Pontic-Caspian steppes (ie. southern Ukraine and Russia north of the Caucuses). The Romance languages, Slavic languages, Germanic languages, non-Dravidian Indic languages, Persian and many isolates all trace back to this common ancestor.
Research indicates that the earliest stages of Proto-Indo-European had two genders (animate and inanimate), as did Hittite, the earliest attested Indo-European language. The classification of nouns based on animacy and inanimacy and the lack of gender are today characteristic of Armenian. According to the theory, the animate gender, which (unlike the inanimate) had independent vocative and accusative forms, later split into masculine and feminine, thus originating the three-way classification into masculine, feminine and neuter.
Many Indo-European languages retained the three genders, including most Slavic languages, Latin, Sanskrit, Ancient and Modern Greek, German, Icelandic, Romanian and Asturian (two Romance language exceptions). In them, there is a high but not absolute correlation between grammatical gender and declensional class. Many linguists believe that to be true of the middle and late stages of Proto-Indo-European.
Sanskrit is an Indo-European language. They are all descended from a most recent common ancestor called Proto-Indo-European, which is thought to have been spoken in the late Neolithic by nomadic horse peoples of the Pontic-Caspian steppes (ie. southern Ukraine and Russia north of the Caucuses). The Romance languages, Slavic languages, Germanic languages, non-Dravidian Indic languages, Persian and many isolates all trace back to this common ancestor.
As for the evolution of grammatical gender within this family :
Interesting!