Key difference: Grammar is the set of rules that are to be followed while speaking or writing in a language. Vocabulary means all the words known and used by a person in a particular language.
Grammar can be roughly defined as a framework of rules and instructions, using which a person can properly construct sentences to speak, or to write in a language.