The capybara and the lesser capybara both belong to the subfamily Hydrochoerinae along with the rock cavies. The living capybaras and their extinct relatives were previously classified in their own family Hydrochoeridae.[7] Since 2002, molecular phylogenetic studies have recognized a close relationship between Hydrochoerus and Kerodon, the rock cavies,[8] supporting placement of both genera in a subfamily of Caviidae.[5]
Paleontological classifications previously used Hydrochoeridae for all capybaras, while using Hydrochoerinae for the living genus and its closest fossil relatives, such as Neochoerus,[9][10] but more recently have adopted the classification of Hydrochoerinae within Caviidae.[11] The taxonomy of fossil hydrochoerines is also in a state of flux. In recent years, the diversity of fossil hydrochoerines has been substantially reduced.[9][10] This is largely due to the recognition that capybara molar teeth show strong variation in shape over the life of an individual. In one instance, material referred to four genera and seven species on the basis of differences in molar shape was later thought to represent differently aged individuals of a single species, Cardiatherium paranense.[9] Among fossil species, the name "capybara" can refer to the many species of Hydrochoerinae that are more closely related to the modern Hydrochoerus than to the "cardiomyine" rodents like Cardiomys. The fossil genera Cardiatherium, Phugatherium, Hydrochoeropsis, and Neochoerus are all capybaras under that concept.[11]