The first attempts to study grammar began in about the 4th cent. B.C., in India with Panini's grammar of Sanskrit and in Greece with Plato's dialogue Cratylus. The Greeks, and later the Romans, approached the study of grammar through philosophy. Concerned only with the study of their own language and not with foreign languages, early Greek and Latin grammars were devoted primarily to defining the parts of speech. The biblical commentator Rashi attempted to decipher the rules of ancient Hebrew grammar. It was not until the Middle Ages that grammarians became interested in languages other than their own. The scientific grammatical analysis of language began in the 19th cent. with the realization that languages have a history; this led to attempts at the genealogical classification of languages through comparative linguistics. Grammatical analysis was further developed in the 20th cent. and was greatly advanced by the theories of structural linguistics and transformational-generative grammar.
The first systematic grammars originated in Iron Age India, with Yaska (6th c. BC), Pāṇini (4th c. BC) and his commentators Pingala (ca. 200 BC), Katyayana, and Patanjali (2nd c. BC). In the West, grammar emerged as a discipline in Hellenism from the 3rd c. BC forward with authors like Rhyanus and Aristarchus of Samothrace, the oldest extant work being the Art of Grammar (Τέχνη Γραμματική), attributed to Dionysius Thrax (ca. 100 BC). Latin grammar developed by following Greek models from the 1st century BC, due to the work of authors such as Orbilius Pupillus, Remmius Palaemon, Marcus Valerius Probus, Verrius Flaccus, and Aemilius Asper.
Tolkāppiyam is the earliest Tamil grammar; it has been dated variously between 1st CE and 10th CE.
A grammar of Irish originated in the 7th century with the Auraicept na n-Éces.
Arabic grammar emerged from the 8th century with the work of Ibn Abi Ishaq and his students.