OAKLAND, Calif. (AP) The Houston Astros realize they can hardly afford many more September slip-ups as they try to hold a slim division lead.

Their advantage in the AL West is down to one game after Texas won at Seattle.

Sonny Gray outpitched close friend Scott Kazmir, and the Athletics spoiled the former Oakland lefty's return to the Coliseum mound with a 4-0 win over the Astros on Tuesday night.

More from FoxSports

''It's always frustrating losing a game, especially at a time like this where we really need to take care of business,'' Kazmir said. ''You have to stay positive, trust what's gotten us here this entire year and we'll be just fine. We can't let a game like this really bother us and we can't let it carry on for tomorrow's game and the series ahead of that.''

Mark Canha hit a three-run homer in the fifth inning after Billy Burns' earlier solo shot to back Gray (13-7). The All-Star right-hander ended a four-start winless stretch and got the best of mentor Kazmir, traded by the A's to his hometown Astros on July 23.

Kazmir had been back to the Bay Area with Houston but didn't pitch against his old team during that trip in early August. He faced A's for the first time since Aug. 18, 2013, with the Indians.

Gray allowed five hits, struck out four and walked two in seven innings. He ended a three-game losing streak with his first victory since beating Houston on Aug. 7.

''The one to Canha is something I look back and kind of just shake my head,'' Kazmir said. ''That's a huge hit right there. We're trying to battle our way back and end up giving up a 3-spot in the fifth inning that's tough to come back from, especially with a guy like Sonny on the mound.''

Ryan Dull pitched the final two innings.

Kazmir (7-10) lost his second consecutive decision. He was tagged for four runs and seven hits in six innings.

''You tell them this is an opportunity to play tomorrow,'' Houston manager A.J. Hinch said. ''We're not going to carry any baggage with us. The drama surrounding multiple losses in a row, it certainly hurts. Our guys know what's at stake. Our guys are ready to play.''

Gray got through a 1-2-3 first on 11 pitches. Kazmir allowed two singles in the bottom half but escaped unscathed on a night when the game-time temperature of 87 degrees was the warmest at the Coliseum all season.

Houston left the bases loaded in the second after Carlos Gomez's leadoff double and a pair of one-out walks. Hank Conger struck out and Jake Marisnick fouled out.

The A's are doing their part to affect the playoff race after holding off the Astros 10-9 on Monday afternoon.

''I had a rough outing my last time so it was important to get back on the mound and put zeros up, give us a chance to win,'' Gray said.

Jed Lowrie was back in Houston's starting lineup after resting for most of Monday's game, but went 0 for 4 with his first hitless game in the last eight. He batted .478 (11 for 23) with three home runs, four doubles and seven RBIs during that stretch.

TRAINER'S ROOM

Astros: The plan is to have lefty reliever Tony Sipp, who hasn't pitched since Aug. 26 because of a troublesome back and oblique, throw off a mound in the next day or so in Houston to rehabbing C Jason Castro. He has been on the disabled list since Aug. 29 with a strained right quadriceps muscle. Both are scheduled to join the team in Anaheim this weekend to continue their recoveries. Sipp played catch two days in a row. Castro has been running on a treadmill and hitting. ''He's going to join us in Anaheim to do a little more aggressive baseball activity,'' Hinch said. ''We're going to try to get him behind the plate in Houston to catch Tony.''

Athletics: C Stephen Vogt had a second ultrasound on his injured groin area after taking a hard foul tip Sunday, and the latest test showed he won't need any procedure. He was home resting for the second straight day, expected to return to the ballpark Wednesday night. It's unclear when or if he will play again this year. ... OF Sam Fuld, who last played on Aug. 30 but hasn't batted since Aug. 25 as he deals with back spasms, could get into the game Wednesday in a defensive role or to pinch run but perhaps isn't quite ready to hit until the weekend.

UP NEXT

Astros: RHP Collin McHugh (15-7) looks to win his third straight start when he pitches the series finale.

Athletics: RHP Aaron Brooks (1-2) tries for his first victory in three starts since being recalled Aug. 29.