BALTIMORE — On an afternoon in which the Baltimore Orioles repeatedly failed to produce in the clutch, they kept on trying until they got it right.

Welington Castillo hit two home runs, including a game-tying shot in the ninth inning, and Mark Trumbo won it in the 12th with an RBI single as Baltimore rallied past the Toronto Blue Jays 5-4 on Sunday.

The Orioles never led until Trumbo hit a liner into the left-field corner off Danny Barnes (2-6) to score Jonathan Schoop in the 12th.

Prior to Trumbo’s hit, Baltimore was 0 for 16 with runners in scoring position.

“I don’t think anyone really noticed,” Trumbo said. “We don’t dissect it like that. You just do what you can. When you get the opportunity, then you want to come through.”

The victory pulled the Orioles within three games of the New York Yankees for the top AL wild-card spot, pending New York’s game against Boston on Sunday night. Baltimore opens a three-game series against the visiting Yankees on Monday afternoon.

Toronto led 4-3 in the ninth before Castillo connected off Roberto Osuna, who was vying for his 36th save. Osuna avoided further damage by retiring Adam Jones with two on and two out, but that didn’t ease the sting of his ninth blown save.

“For the first time today, I take full responsibility,” Osuna said. “Before, it was like little bloopers and stuff like that. Today, I thought I had the guy with that cutter but he got the best of me.”

Jimmy Yacabonis (2-0) pitched the 12th for the Orioles, now 6-62 when trailing after eight innings.

“This is crunch time, so we would have been real disappointed if we didn’t get the job done,” Trumbo said.

Josh Donaldson homered for the last-place Blue Jays, who had to settle for a split of the four-game series. Donaldson’s second three-run shot in as many games, off Chris Tillman, staked Toronto to a 3-0 lead in the third inning.

Castillo homered in the third and Trumbo went deep in the fourth, and Baltimore used a double by Schoop and a sacrifice fly by Trey Mancini to tie it in the sixth.

In the seventh, Ryan Goins doubled off the glove of third baseman Manny Machado and scored on an infield hit by Teoscar Hernandez.

Toronto played a second straight game without manager John Gibbons, who is dealing with a personal matter. Bench coach DeMarlo Hale ran the club.

“We are competing for those nine innings or however many innings it takes,” Hale said. “Osuma has been good. He just didn’t execute that one pitch.”

THIS AND THAT

Toronto’s Carlos Ramirez made his second big league appearance and pitched two scoreless innings, as he did on Friday night. The converted outfielder has not given up an earned run in either the big leagues or minors this year. … Castillo has five career multihomer games, including two this year — both against the Blue Jays. … Baltimore improved to 12-2 in extra innings.

ROSTER MOVES

Blue Jays: Recalled RHP Chris Rowley from Triple-A Buffalo.

Orioles: Recalled RHP Gabriel Ynoa and optioned RHP Alex Asher to Double-A Bowie.

TRAINER’S ROOM

Blue Jays: RHP Marcus Stroman said his bruised right elbow was sore, one day after he was struck by a line drive off the bat of Trumbo.

Orioles: The return of SS J.J. Hardy (wrist) has been put on hold because of elbow soreness. Hardy received an injection to help alleviate the pain on Saturday, and says it will be at least a few days before he’s activated from the DL because he hasn’t swung a bat since the shot.

UP NEXT

Blue Jays: JA Happ (6-10, 3.96 ERA) helps Toronto open a three-game series at Boston on Monday night.

Orioles: Dylan Bundy (13-8, 3.94 ERA) seeks an encore to his 1-hitter against Seattle in a matchup against New York lefty Jordan Montgomery (7-7, 4.15 ERA).


More AP baseball coverage: https://apnews.com/tag/MLBbaseball