Gray responded by limiting the Seattle Mariners to just six hits and one unearned run while pitching into the eighth inning Sunday as the Athletics won 4-1.
''You know it's a big game, an important game for us after losing the first two,'' Gray said. ''You never really want to get swept, so going in I knew it was a game we needed to win. I was just going to do my best to help us do that.''
Gray (10-3) walked two and struck out five over 7 2/3 innings.
The Athletics are 59-36 and 1 1/2 games ahead of the division rival Los Angeles Angels for the best record in baseball.
''We've leaned on him as hard as you can lean on a young pitcher since the time he's gotten here,'' manager Bob Melvin said. ''Nothing surprises me with him. He really wanted to go out there and give us that type of effort today so we'd have a good feeling going into the break.''
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. 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.
''I was going at them with my best stuff,'' Gray said. ''I was nibbling, but nibbling in my strength spots hoping to get soft contact and was able to do that.''
After managing just one hit off Chris Young (8-6) through four innings, the Athletics broke through in the fifth.
Jed Lowrie reached with a one-out double. After Andy Parrino walked, Craig Gentry singled to center and Lowrie beat the throw home to tie it at 1. John Jaso followed with a go-ahead single.
''From about the third inning on we weren't swinging at the letter-high pitch and that's the key with (Young),'' Melvin said. ''It looks like it's 85 miles per hour, but it's chest high. It plays better than that because of his height.''
''We made him throw some pitches and we made him get some balls down and had a couple hits off of him that were key,'' he said.
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.
''He's such a different arm angle. He's so tall and he throws so funky that it takes a little bit to get your timing on him,'' Moss said.
Young allowed three runs and five hits.
''There is a reason they have the best record in baseball,'' Young said. ''Sonny Gray was outstanding today and we just came up short.''
Nick Punto added a solo homer off Joe Beimel in the ninth for the Athletics.
NOTES: The Athletics' starting rotation after the All-Star break will feature Jeff Samardzija, Jason Hammel and Gray against Baltimore with Scott Kazmir and Jesse Chavez going against Houston. ... Seattle will start Hisashi Iwakuma, Felix Hernandez and Young against the Angels, with Roenis Elias lined up to start against the New York Mets. ... The A's reinstated LHP Drew Pomeranz from the disabled list and optioned him to Triple-A Sacramento prior to the game. ... Mariners reliever Joe Beimel had his streak of 19 consecutive scoreless innings snapped by Punto's home run.