Yan Gomes hit a three-run homer to help the Cleveland Indians keep their slim playoff hopes alive with a 6-4 win over the Kansas City Royals on Wednesday.

Michael Brantley went 3-for-4 with a run scored, while Jose Ramirez, Carlos Santana and David Murphy all had an RBI for the Indians, who would have been eliminated from playoff contention with a loss.

Zach McAllister (4-7) earned the win for tossing 2 1/3 scoreless innings in relief of starter Trevor Bauer, who allowed four runs on eight hits over 4 1/3 frames.

“I thought he started leaving pitches up,” Indians manager Terry Francona said of his starter. “He had some good offspeed pitches.”

Brandon Finnegan (0-1) was charged with the loss in his first-career decision for Kansas City, which had its three-game winning streak snapped and now trails Detroit by two games in the AL Central.

Billy Butler finished with three RBI and Eric Hosmer knocked in a run for the Royals, who remain tied with Oakland for the AL wild card lead. Their magic number to clinch a playoff berth for the first time since 1985 is down to two games courtesy of Seattle’s loss against Toronto.

Billy Butler (photo/MLB)

Billy Butler (photo/MLB)

“We have to go to Chicago and take care of business,” Butler said of Kansas City’s upcoming series against the White Sox.

Cleveland jumped all over Kansas City starter Jason Vargas right out of the gate with timely two-out hitting. Brantley extended his hitting streak to 15 games with a single to right, Santana walked and Gomes launched his 21st homer of the season to give the Indians a 3-0 lead.

Vargas worked around a leadoff double in the second, then KC finally gave the southpaw some support in the fourth. Lorenzo Cain reached on a bunt single, moved to second on Hosmer’s groundout and used some smart baserunning to score on Butler’s bloop single to left. With two outs and a pair of runners on, Omar Infante reached on a dribbler to first as Bauer was late covering the bag. The right-hander maneuvered his way out of further damage, however, getting Mike Moustakas to fly to left for the final out.

The Royals answered Cleveland’s three-run first with one of their own in the fifth, knocking Bauer out of the game in the process. Singles from Alcides Escobar and Nori Aoki to begin the inning set up Hosmer’s RBI hit which cut the deficit to one. Butler followed by driving a two-run double to the left- center gap for a 4-3 lead.

Cleveland responded with a pair of runs in the fifth to regain the lead, then added an insurance run in the sixth. Michael Bourn was hit by a pitch to begin the home fifth and raced home when Ramirez ripped a double off the scoreboard in left-center to tie the game. Brantley proceeded to single which put runners at the corners, and Ramirez scored a batter later on Santana’s groundout. The Indians manufactured their run in the sixth when Mike Aviles walked to lead off the inning, stole second, moved to third on a groundout and scored on Murphy’s sacrifice fly.

Hosmer doubled with two outs in the ninth, but Cody Allen managed to get Butler on a lineout to right for his 23rd save of the season.