OAKLAND, Calif. — A big pinch-hit double by seldom-used Tyler White in the eighth inning and little discipline at the plate by Marwin Gonzalez in the ninth provided just enough to keep the Houston Astros on the fringe of the AL wild card race.

Manager A.J. Hinch’s ballclub might be down — three games, in fact — but they’re certainly not out.

White hit a game-tying double in the eighth and Gonzalez followed with a two-run single off Ryan Madson in the ninth and the Astros came from behind to beat the Oakland Athletics 4-2 on Monday night.

“We need them all, I loved how our team hung in there until the end,” Hinch said. “Some of the biggest at-bats were when the game was on the line. I liked how we gutted it out.”

Houston remains three games behind Baltimore and Toronto in the race for the AL wild card spots. Two other teams, Detroit and Seattle, are also in front of the Astros.

“We’re fighting to the end,” Gonzalez said. “Nobody’s quitting. We’ve got to fight until the end.”

The Astros trailed 2-1 going into the eighth inning but tied it on White’s RBI-double then they scored twice in the ninth to keep their slim playoff hopes alive.

Jose Altuve and Carlos Correa opened the inning with singles. After Evan Gattis was intentionally walked, Gonzalez lined the first pitch from Madson (5-7) into center field to drive in Altuve and Correa.

“He didn’t get too big,” Hinch said of his switch-hitting first baseman. “Sometimes our guys, they want to win so badly, you want to be the guy, we can come out of our swing a little bit. Not tonight.”

Correa finished with two hits while Gattis hit his 28th home run of the season to help the Astros to their fifth straight win over the A’s.

Former Oakland reliever Luke Gregerson (4-1) retired three batters for the win. Ken Giles pitched the ninth for his 12th save.

Ryon Healy and Bruce Maxwell hit solo home runs for the A’s, who had won six of seven before the bullpen allowed three runs in two innings and wasted a strong start by rookie Jharel Cotton.

Cotton allowed one run over six innings. The right-hander retired 18 of the 20 batters he faced, allowing Gattis’ home run in the second. He struck out six.

“Every time out he looks like the same guy,” A’s manager Bob Melvin said. “He’s locating all his pitches, his changeup in any count, and his curveball was probably better today than we’ve seen it. He pitched great.”

CLOSING IN ON 200 AGAIN

Altuve went 1 for 4, leaving him one hit shy of 200. Altuve is attempting to become the first player since Ichiro Suzuki to have 200 or more hits in three consecutive seasons.

PEACOCK CAN STRUT

Houston starter Brad Peacock allowed two runs over 5 1-3 innings, walked two and struck out two. Peacock, who was the A’s top pitching prospect before being traded to the Astros in 2013, extended his career-long streak for allowing three earned runs or fewer to 10 consecutive games. The streak dates to 2014.

TRAINER’S ROOM

Athletics: RHP Sonny Gray (strained right forearm) will throw a bullpen session Tuesday and if all goes well, the Oakland ace will face hitters in his next step of rehab. The team is still hopeful of getting Gray into a game before the end of the season. … Henderson Alvarez will undergo a second surgery on his right shoulder Tuesday. Alvarez has not pitched in the majors since May 22, 2015. … 1B/OF Mark Canha will begin hitting off a tee as he attempts to return from a back strain that has kept him out since May 9.

UP NEXT

Astros: RHP Joe Musgrove (3-4) starts against Oakland on Tuesday. The rookie beat the A’s earlier this season when he pitched 5 1-3 scoreless innings.

Athletics: LHP Sean Manaea (6-9) makes his second start since missing 15 days with a strained left rhomboid.