UNM athletic director Eddie Nunez made the announcement Tuesday night. Contract terms weren't immediately released.
Gonzales, 43, who has spent the past two seasons leading ASU's defense, played safety at New Mexico and began his coaching career there under Rocky Long. After stints as a graduate assistant and as the team's video coordinator, Gonzales coached safeties and special teams for the Lobos from 2006 to 2008. He then joined Long at San Diego State, where he spent seven seasons, including the final one as defensive coordinator.
Gonzales replaces Bob Davie, who had a 35-64 record in eight seasons.
In Gonzales' first season at ASU, the Sun Devils allowed their lowest point total (332) since 2012. Arizona State has allowed 277 points entering its Sun Bowl matchup against Florida State.
TCU running backs coach Curtis Luper and Weber State head coach Jay Hill also were considered for the job.
The Associated Press contributed to this report.