TORONTO -- Pinch-hitter Hyun Soo Kim hit a two-run homer off Roberto Osuna in the ninth inning as the Baltimore Orioles came back for a 3-2 victory over the Blue Jays on Wednesday at Rogers Centre.

Kim took a 3-2 pitch from the Toronto closer over the wall for his sixth homer of the season. Orioles closer Zach Britton recorded three straight outs for his 47th save in 47 opportunities.

The Blue Jays wasted a solid outing from Toronto starter Francisco Liriano, who struck out 10 batters over 6 1/3 innings.

The loss left Toronto (87-71) one game ahead of the Orioles in the race for the first wild-card spot in the American League. The teams will play the rubber game of the three-game series on Thursday night.

Toronto scratched out runs early in the game with sacrifice flies. Ezequiel Carrera opened the scoring in the first inning and Troy Tulowitzki added another run in the second.

The teams put up zeros until the eighth when Baltimore's Mark Trumbo turned on a Jason Grilli pitch for his major league-leading 46th homer of the season.

With Devon Travis getting another night off to rest his sore shoulder, Carrera batted in the leadoff spot and reached when first baseman Chris Davis dropped a hurried shovel toss from Orioles starter Chris Tillman.

A wide throw on a pickoff attempt allowed Carrera to scamper to third base and he scored when Edwin Encarnacion drove a ball to the warning track.

In the second inning, Tulowitzki hit a one-out double and moved to third on a Michael Saunders single. Kevin Pillar hit a fly ball into right field and Tulowitzki wisely tested Trumbo's arm to make it 2-0.

Liriano was perfect his first time through the Baltimore order. Adam Jones was the first Oriole to reach base when he led off the fourth inning with a sharp single.

Jones advanced when Davis stroked a ball to the vacant left side with Toronto playing the shift. Liriano responded by fanning Manny Machado, Trumbo and Trey Mancini to the delight of the announced crowd of 44,668.

The Orioles (86-72) threatened again in the fifth inning by loading the bases for Davis, who was caught looking for Liriano's ninth strikeout of the game.

Tillman gave up back-to-back walks in the Toronto half of the sixth but was helped by a great sliding catch by left-fielder Nolan Reimold on a Tulowitzki flare. Jose Bautista had already rounded third base and was easily doubled off.

Southpaw Donnie Hart relieved Tillman and got Saunders to pop up for the third out. Tillman allowed one earned run, six hits, three walks and struck out a pair.

Liriano was pulled after giving up a one-out single to Jonathan Schoop in the seventh, allowing Matt Wieters to move to second base. Left-hander Brett Cecil came on and fanned Reimold before getting Jones to ground out.

Liriano, who gave up six hits and a walk, trimmed his earned-run average to 4.69 from 4.88.

The Blue Jays loaded the bases in the eighth but Brian Duensing (1-0) struck out pinch-hitter Melvin Upton Jr.

In the ninth, Osuna (3-3) gave up a one-out single to Schoop and pinch-runner Michael Bourn stole second to set the stage for Kim.

The game took three hours four minutes to play. Baltimore outhit Toronto 11-6.

Notes: It was the first time in over five years that Toronto starters have recorded back-to-back games of 10 strikeouts or more. Aaron Sanchez fanned 10 in a 5-1 victory on Tuesday night. Brandon Morrow and Ricky Romero last achieved the feat on April 23-24, 2011. ... Toronto's Marcus Stroman (9-9, 4.34 ERA) is scheduled to start on Thursday night against fellow right-hander Ubaldo Jimenez (7-12, 5.71). ... The Blue Jays will close out the regular season with a three-game weekend series at Boston while the Orioles will play three games in New York.