Facing the A's for the first time in his five-year career, Miley (2-4) allowed the leadoff batter to reach in four of his first six innings. The left-hander won for the first time since April 21 at Tampa Bay, allowing four walks and five hits in 6 2-3 innings.
Gray (4-1) struck out nine and didn't walk a batter for the first time all season. but the A's dropped to 1-11 in the daytime with their seventh loss in eight games.
Daniel Nava hit an RBI single in the second to snap an 0-for-20 slide and drive in the first run. The Red Sox won on the road for just the fourth time in their last 11 away from Fenway Park.
Boston added an unearned run on shortstop Marcus Semien's wild throw to first in the eighth. Oakland has made errors in 11 straight games and a majors-high 36 in all.
Koji Uehara pitched the ninth for his seventh save. Boston won this series without big contributions from the middle of the batting order. Nos. 3-4-5 hitters David Ortiz, Hanley Ramirez and Pablo Sandoval went a combined 5 for 36.
Sandoval hit a winning home run in the 11th inning Monday night but wrapped up his Bay Area return 1 for 12 and was booed whenever he stepped in the batter's box. He received his World Series ring from Giants manager Bruce Bochy on Sunday night.
Ortiz went 2 for 13 this series and is 3 of 20 on the trip. Ramirez singled in the second and ninth for his only hits in a 2-for-11 Oakland stop.
Gray, with nine or more strikeouts for the third straight start, was trying to extend his best start to a season. He missed matching his career-best winning streak of six straight decisions dating to his last loss Sept. 23 against the Angels. He has allowed one earned run or fewer in six of his first eight starts.
The A's snapped a season-high six-game losing streak in Tuesday night's 9-2 win, but couldn't build momentum to win back-to-back games -- something they haven't done since their lone winning streak April 13-14 at Houston.
Coco Crisp hit an infield single to begin the fifth for his first hit of the year -- snapping an 0-for-26 funk with his first hit in 40 at-bats dating to last Sept. 26 -- before Semien grounded into a double play and Josh Reddick flied out for another missed chance.