Maikel Garcia scored on a wild pitch in the ninth inning and the Kansas City Royals snapped their eight-game losing streak with 6-5 win Tuesday night against the Baltimore Orioles at Kauffman Stadium.

Ryan Helsey (0-2) walked Garcia and Bobby Witt Jr. to open the ninth with the game tied at 5. The runners reached second and third base on a wild pitch, and Garcia darted home to score the winner on another wild pitch from Helsey — Baltimore’s fourth of the game — that bounced onto the infield grass.

Kyle Isbel had three hits and Michael Massey clubbed a tying solo homer in the eighth for the Royals, who overcame an early 3-0 hole for their first win since April 11.

Lucas Erceg (1-1) pitched one scoreless inning as Kansas City evened the three-game set heading into this afternoon’s finale.

Adley Rutschman came off the 10-day injured list to hit a two-run go-ahead homer in the eighth for the Orioles, who have lost six of their past eight.

Kansas City’s Kris Bubic opened the second inning by allowing a single to Jeremiah Jackson and a walk to Weston Watson. With one out, Coby Mayo sent a drive well into the left-field seats for a 3-0 Baltimore lead.

Those were only runs yielded by Bubic in 6 1/3 innings. He allowed five hits and three walks while striking out three.

Kansas City got a run back in the bottom of the second. Carter Jensen doubled, went to third on Shane Baz’s wild pitch and scored via a sacrifice fly by Massey.

The Royals tied the contest in the fifth. Isbel doubled and scored on a single by Garcia, who eventually came home courtesy of Vinnie Pasquantino’s sacrifice fly.

Kansas City took the lead in the seventh when Isbel doubled down the left line, went to third on another Baz wild pitch and scored on Witt’s sacrifice fly to right.

The Orioles regained the lead in the eighth. Rutschman, with a man aboard, barely cleared the left-center-field wall off Matt Strahm to make it 5-4 with his first homer of the season.

Massey’s towering homer leading off the bottom of the eighth was first hit allowed by Baltimore’s Rico Garcia in 12 appearances this year.

Baz yielded four runs and eight hits in 6 1/3 innings. He fanned four and walked two.