Steven Madison hit two free throws with 30 seconds remaining in the game to put the Idaho up by one, 66-65. Lacy drove the lane on the next possession but missed the layup. Shelton was fouled on the rebound with seven seconds on the clock and converted both.
Connor Hill missed an open three from the corner as time expired.
Royce Woolridge added 13 points as Washington State (4-4) recovered from a ten-point, second-half deficit.
Stephen Madison had 16 points and went 9-10 from the free throw line for Idaho (4-5). Hill added 15 points and Glenn Dean chipped in 14.
It was WSU's 10th straight win over Idaho.