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 the Baltimore Orioles 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.

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 one and two out.

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