Language has two important aspects that work together in order to convey comprehension.
Syntax deals with sentence construction and semantics involves meaning. Each informs the other to some degree, but they can also stand apart.
Because of this distinction, I can say that something is syntactic but ambiguous:
They are cooking apples.
Is it a group of people preparing apples to eat or is it a description of apples meant for cooking?
I can say that something is syntactic but nonsensical:
Colourless green ideas sleep furiously.
From the linguist Noam Chomsky. Further information about this can be found at the Futurity website in the article “Chomsky Told Us: We Have Grammar In Our Heads” by James Devitt-Nyu.
And I can say that something is asyntactic but comprehensible:
All your base are belong to us.
I can haz cheeseburger?
When people use the word grammatical, I’ve found that what they often mean is syntactic. However, I’ve also encountered situations where people will mean semantic, arguing that something is grammatical because it’s used and understood—even if it goes against common “rules” of grammar and lexicography.
This distinction can also shift from one discussion to the next, where somebody will change their usage of the word depending on their agreement or disagreement with something that they’ve heard.
As such, if you’re going to be precise, it’s sometimes best to not say grammatical at all but use the specific language words for what you’re trying to convey.