Gray earned his 10th victory and Sean Doolittle recorded the final four outs for his 14th save.
James Jones singled and advanced to third on an errant pickoff attempt from Gray. Jones scored on an RBI groundout from Robinson Cano to give the Mariners a 1-0 lead in the first.
Seattle squandered an opportunity to add to its lead in the fourth inning. Cano and Kyle Seager singled to put runners on the corners with no outs. Gray worked out of the jam with a strikeout of Dustin Ackley leaving the runners stranded.
After managing just one hit off Seattle starter Chris Young (8-6) through four innings, the Athletics broke through in the fifth inning.
Jed Lowrie reached with a one-out double. After an Andy Parrino walk, Craig Gentry singled to center and Lowrie beat the throw home to tie the game at 1-1. John Jaso followed with a single to drive in Parrino and give Oakland the lead.
Brandon Moss hit his 21st home run of the season into the right field seats to extend the A's lead to 3-1 in the sixth.
Young (8-6) allowed three runs and five hits with just one walk and two strikeouts for Seattle.
Endy Chavez singled and advanced to second on a groundout from Jones in the eighth inning. Gray intentionally walked Cano to bring Seager to the plate. Sean Doolittle relieved Gray and got Seager to pop out to shortstop.
Nick Punto added a solo homer off Joe Beimel in the ninth for the Athletics.