Grant Watson earned his 26th career win, making him the winningest LHP in UCLA history.
James Kaprielian struck out nine batters over eight innings and David Berg earned his fifth save.
The Bruins carry a 5-1 Pac-12 record into a three-game road series against the Cougars.
Ty Moore launched the game-winning three-run home run, his second of the year, in the 13th inning.
The Bruins are undefeated (4-0) in midweek games this year and have topped SDSU four-straight times.