Williams finished 12-of-16 from the field overall.
Alex Kirk provided 19 points, 10 rebounds and three blocks as New Mexico (23-4, 10-2 MWC) strengthened its grip on the Mountain West Conference lead.
Tony Snell also reached double figures with 10 points for the Lobos, who handed the Rams their first home loss in 27 games stretching back to Nov. 19, 2011.
Colton Iverson led Colorado State (21-6, 8-4) with 26 points and 15 rebounds.
The Rams got 22 points from Wes Eikmeier and 20 from Dorian Green.
Caroline Berg Eriksen: Soccer player's wife triggers debate with post-birth selfie
18-year-old elf alleges mall Santa pinched her buttocks on the job