I don't think this question can be answered with "either/or". (And I think this question is on the verge of being off-topic here: Case is not a grammar aspect unique to German)
Case both drives semantics and marks syntactical elements (and is not necessarily "based on"):
Nominative (in any language) marks the subject of a sentence, objective case the object. So case definitely acts as a syntax marker. For some languages more, for others less (strict SPO languages like English don't really need such markers, as their syntax is clearly defined through word order only, while German with a more flexible order has a bit of a higher need for grammatical case marking syntax elements).
On the other hand, case also conveys semantics: Genitive may convey possession, dative may mark a receiver, languages that have an ablative may mark separation, removal or instrumentation through it.
Very generally, I'd say, the more cases a language has, the more semantics it may be able to convey through them. In a language that basically only has an objective case (like English, for example), the possible selection to convey semantics is limited, while languages that have more cases might be able to express more by just applying a specific case to a word (don't read this as "being more expressive" - that's not what I'm trying to say).
Grammatical case might also act as a modifier to prepositions: the German "in" is a good example - used with accusative, it conveys movement to somewhere, used with dative, it conveys "at or around" some place - clearly a semantic function.
I'm pretty sure you could devise a (very complex and very unruly) syntax for any language that swallows all those semantical elements completely: Two alternative (I'm sure, oversimplified, but this is just to illustrate the idea) examples could be:
<General Sentence> ::= <Subject> <Predicate> <Object>
<Sentence with Object and Receiver> ::= <Subject> <Predicate> <Dative Object> <Accusative Object>
and you've built the semantical aspect of case completely into the syntax.