New Mexico State gained control of the game early in the second half, reeling off a 13-0 run while holding the Lobos scoreless for 4½ minutes to go up 60-44.
In the final two minutes, New Mexico trimmed a 92-79 deficit to 96-94 before C.J. Bobbitt hit two foul shots with 0.7 seconds left to seal it.
New Mexico State now has won four straight in the bitter rivalry for the first time since the 1993-94 seasons. The teams will meet again Dec. 4 in Las Cruces, N.M.
The Lobos still own the overall advantage 121-100 and 36-16 in the Pit. New Mexico coach Paul Weir, who coached the Aggies for one season and was an assistant with New Mexico State for nine seasons before taking on the Lobos program before the 2017-18 season, is 0-3 against his former team.
New Mexico State next plays ag home Nov. 21 against Division II-member Eastern New Mexico. The Aggies have a 621-154 in the Pan American Center and 140-24 over the last 10 years.
New Mexico next plays Nov. 24 at home against former Western Athletic Conference rival UTEP. The Miners are 1-2 and lost to New Mexico State by 27 points Nov. 9.