Syntax is the structure of a language, while grammar is the set of rules that govern how words are used and combined to form meaningful sentences.