OAKLAND, Calif. — Jharel Cotton was impressive again in his third major league start. He left the game with a lead that didn’t last for the Oakland Athletics.

Marwin Gonzalez hit a tiebreaking, two-run single off Ryan Madson in the ninth inning and the Houston Astros came from behind to beat the A’s 4-2 on Monday night.

Cotton allowed one run and two hits over six innings. The rookie right-hander retired 18 of the 20 batters he faced, striking out six and walking none.

“Every time out he looks like the same guy,” Oakland 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.”

Cotton, acquired in a trade with the Los Angeles Dodgers this summer, has yielded just three earned runs in 18 innings over his first three starts with Oakland.

“It’s been fascinating so far. I’m just hoping to keep it going,” he said. “We have a good group of guys behind me pushing me and pushing me to get better.”

The Astros trailed 2-1 going into the eighth but tied it on pinch-hitter Tyler White’s RBI double. They scored twice in the ninth to help their chances in the crowded AL wild-card race.

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.

“I’m trying to get a force at home,” Melvin said, explaining his decision to walk Gattis. “I’m not going to get Altuve at home on a groundball without a force play.”

Ryon Healy and Bruce Maxwell each hit a solo homer for the A’s, who had won six of seven.

The left-handed-hitting Maxwell’s homer, an opposite-field shot, was his first in the majors.

“That’s where a lot of my power is,” he said. “It felt good to finally get one.”

Melvin was pleased, too.

“In the minor leagues he wasn’t showing a lot of power, but certainly now he’s pulling the ball a little bit more and getting the ball a little more elevated, whereas earlier in his career he was more of a line-drive guy hitting the ball to left field,” the manager said. “His offense is really coming around.”

Correa finished with two hits and Gattis hit his 28th home run to help the Astros win their fifth straight against 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.

Houston is tied with Seattle, three games behind co-leaders Baltimore and Toronto for the two AL wild cards. Detroit is a half-game in front of the Astros and Mariners.

CLOSING IN ON 200 AGAIN

Altuve went 1 for 4, leaving him one hit shy of 200. He 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. Peacock, the A’s top pitching prospect before he was traded to the Astros in 2013, extended his career-best streak for allowing three earned runs or fewer to 10 consecutive games. The string dates to 2014.

TRAINER’S ROOM

Athletics: Sonny Gray (strained right forearm) will throw a bullpen Tuesday and if all goes well, the Oakland ace will face hitters in the next step of his 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.