The Rays overcame a 4-1 deficit to snap a six-game losing streak and move within three games of Boston for the lead in the American League East. The Red Sox fell to Toronto 4-3 in 10 innings.
Danny Farquhar came on in the ninth for Seattle to protect a 4-3 lead and immediately gave up a triple to Ben Zobrist.
Wil Myers was intentionally walked to load the bases and Bourgeois followed with his drive to deep right that was scored as a single.
Farquhar (0-1) suffered his first major league loss after having been successful in five straight save opportunities.
Myers had brought the Rays within one with a two-run homer in the sixth. The win went to Joel Peralta (2-5), who worked a perfect top of the ninth.
Seattle grabbed a 4-1 lead with a three-run fifth that included a two-run triple from Brad Miller.