The only free and comprehensive online etymological dictionary of the Spanish language
zaga f. (Noun) "rear"
12th cent. From Andalusian Arabic sáqa 'id.' From Arabic sāqah "rearguard."
Variants
Andalusia azagador (trashumance) "royal path for cattle," azagar "to drive cattle in a line," probably borrowed from Aragonese azagar
Indo-European
Romance
Aragonese azagar "to drive cattle in a line," Catalan assagador "farmer's path"

The word is not the origin of the surname Zaga. The surname, according to Tibón (1988), was originally given to Sephardic Jewish families and is of unknown origin. Tibón speculates the surname may derive as an apocopation of Zagarolo, name of a town near Rome, Italy.