HOUSTON (AP) The Oakland Athletics continued their late-inning magic on Thursday, and it helped them to a series win over the Houston Astros.

Mark Canha's two-RBI single in Oakland's three-run eighth inning lifted the Athletics to the 6-4 victory. The Athletics fell behind early but cut the lead to one with a three-run fifth. An RBI double by Matt Chapman tied it with no outs in eighth before Canha's single off Chris Devenski (2-2) with one out made it 6-4.

Canha's hit landed in the corner of left field and the Astros challenged the ruling that the ball was fair, but the call was upheld.

It was another big eighth inning for the A's, who lead the majors with 69 runs in the inning this season. This one helped them take three out of four against the Astros. They've won eight games this season when trailing after seven innings, which is also the most in the majors.

"When you do it so many times, you have confidence doing it," manager Bob Melvin said. "And it was different guys today, too. At this point, it's a true team effort and that's powerful when you have 25 guys contributing."

Nick Martini had three hits and drove in two runs for the Athletics, who are 19-5 in their last 24 games but still trail the first-place Astros by eight games in the AL West.

Yusmeiro Petit (3-2) allowed one hit in 2 1/3 scoreless innings. Ryan Buchter took over for the eighth and made back-to-back nifty plays to pitch a perfect inning.

The first one came when a comebacker by Yuli Gurriel hit him on the thigh and rolled away from the mound. He chased it down and made a barehanded throw that beat Gurriel to first. Two pitches later, Buchter mishandled a dribbler by Josh Reddick before scooping it up and flipping it to first for the out.

Melvin said 6-foot-5 first baseman Matt Olson helps make those kinds of plays easier.

"The glove flip was big, but that's what happens when you have a Gold Glove-caliber first baseman over there," he said.

Lou Trivino struck out two in the ninth for his fourth save in five opportunities.

Alex Bregman drove in two with a double in the third and Tony Kemp's two-run homer made it 4-0 in the fourth.

"We knew coming in they were playing well and we see why," Houston manager A.J. Hinch said of the Athletics. "They did a lot more right than we did during the series. They completed games, made us work and kind of wore us out and came up with big at-bats when they needed to. We got outplayed this series."

Oakland starter Trevor Cahill went 3 2/3 innings in his first start since June 2 after spending more than a month on the disabled list with an Achilles injury. He allowed three runs on three hits and walked three.

Houston's Charlie Morton allowed six hits and three runs in 4 1/3 innings.

Khris Davis extended his career-long hitting streak to 14 games with a single to get things going in the eighth, and Olson followed with a single. The double by Chapman to left field scored Davis to tie it at 4.

Cahill walked Kemp and Springer in the third, and both moved up a base on a wild pitch before scoring on the double by Bregman.

Max Stassi singled with two outs in the fourth to chase Cahill. He was replaced by Chris Hatcher, who was greeted by the two-run homer by Kemp.

Chad Pinder and Canha hit consecutive singles to start the fifth inning before Jonathan Lucroy walked to load the bases. The Athletics cut the lead to 4-2 on a double to right field by Martini.

Stephen Piscotty hit an RBI double with one out to end Morton's day.

TRAINER'S ROOM

Astros: INF Marwin Gonzalez returned after missing a game after taking a cleat to the left wrist on Tuesday night. ... SS Carlos Correa (back stiffness) will have to go on a rehabilitation assignment before he comes off the disabled list, so he will not play before the All-Star break.

STAR-STUDDED JERSEY HANDOUT

Houston Texans star J.J. Watt presented the Astros with their All-Star jerseys in a pregame ceremony. Watt, a three-time NFL Defensive Player of the Year, handed out the jerseys to Jose Altuve, Bregman, George Springer, Justin Verlander and Hinch, who will manage the AL team. Right-hander Gerrit Cole, who also made the team, was not involved in the ceremony because he is away from the team following a death in his family.

UP NEXT

Athletics: Edwin Jackson (1-0, 2.45 ERA) will start for Oakland in the opener of a three-game series against the Giants on Friday night. Jackson needs one win to reach 100 for his career.

Astros: Houston's Dallas Keuchel (6-8, 3.95) opposes Detroit's Mike Fiers (6-5, 3.65) when the Astros and Tigers open a three-game series on Friday night. Keuchel has won three straight decisions after dropping his previous three, and Fiers, who threw Houston's last no-hitter in 2015, won his last start after losing his previous two decisions.