As defined from the NOAD, grammar is, "the whole system and structure of a language or of languages in general, usually taken as consisting of syntax and morphology (including inflections) and sometimes also phonology and semantics."
It includes the syntax, but it's not limited to that.
The syntax of a language is, "the arrangement of words and phrases to create well-formed sentences in a language."
For example, the syntax is about which order subject, verb, and object have in a sentence to form a well-formed sentence. A sentence like "like it I" is not considered a well-formed sentence, basing on the English syntax, even if people would understand that the correct sentence is "I like it."