Gagner assisted on a goal by Jordan Eberle in regulation to help the Oilers end a three-game losing streak.
Devan Dubnyk had 28 saves in the game and turned aside all three of the Sharks' tries in the shootout.
Jim Vandermeer and Ryane Clowe both scored for the Sharks, who trail first-place Dallas by three points in the Pacific Division and are tied with Los Angeles and Colorado for eighth place in the Western Conference. San Jose went 1-2-1 on its four-game home stand.
Antti Niemi stopped 24-of-26 shots.
Clowe's goal at 15:19 of the second period gave San Jose a 2-1 edge. Ryan Smith connected less than 1 minute later on a slap shot from the left circle to tie the game and set the stage for overtime.
Celebrity Couples of 2014 [PHOTOS]