Ganar (Spanish for “to win”) comes from the old Germanic root waidanjan, meaning “to hunt”. From the same root, via French, we get the English… gain.
The g-n pattern is clearly visible in both.
Interestingly, this is almost an example of the w- to g- pattern, like guerra and war. It has the original w- root in the original word but the modern words, in both Spanish and English, use the g- sound (since the English word came indirectly from Latin via French).