The letter gamma had two uses in Ancient Greek: first, as a voiced velar stop or fricative, something like the "hard" g in English or Spanish; and second, as a velar nasal, like the sound at the end of 'bang'.
Gamma would take its nasal sound when it came before another velar (a chi, a kappa, or another gamma), e.g., they would write "aggelos" where we would use "angelos". It would also take its nasal sound before mu.
Agma was the Greek name for the gamma-as-nasal.