Baltimore Orioles manager Buck Showalter considered taking Matt Wieters out of the game after the catcher took a hard foul ball off his mask in the fifth inning.

That proved to be a game-changing decision.

Wieters hit a go-ahead, two-run homer off Jason Grilli in the eighth to lead the Orioles to a 5-3 victory over the Toronto Blue Jays on Tuesday night.

Baltimore pulled within three games of the first-place Blue Jays, who had a four-game winning streak snapped. After losing the opener 5-1, the Orioles will look to gain more ground in the series finale Wednesday.

"It's a big game," Wieters said. "We're going to be playing a lot of teams in the division, so there are going to be a lot of big games. I think the key is to be able to enjoy this one and move on tomorrow. We've got to come back and win another one tomorrow."

Michael Saunders drilled a two-run shot off Orioles starter Ubaldo Jimenez that tied the game 3-3 in the seventh.

In the eighth, Jonathan Schoop walked and Wieters homered off Grilli (4-2), his 12th of the season.

"Matt took a ball right in the kisser tonight and I've seen a lot of people come out of the game," Showalter said. "We would have taken him out of the game, mostly because he took one in the same place last night."

Brad Brach (8-2) picked up the win with 1 1/3 scoreless innings. Zach Britton got his league-leading 39th save.

Blue Jays left-hander J.A. Happ fell short of tying Boston's Rick Porcello for the major league lead with 18 wins. Happ allowed three runs and six hits with three strikeouts over 6 1/3 innings.

"I wasn't at my best tonight but this is an elite team, especially at home," Happ said. "They're tough. I think I made a couple mistakes; they made me pay. But we battled them all night. I gave us what I had tonight, which wasn't a ton but it was enough to keep us in the ballgame."

Manny Machado hit his 34th homer of the season and 100th of his career for Baltimore. Steve Pearce went deep for the 13th time this season.

Baltimore's Pedro Alvarez, who got a rare start against a left-hander, managed two hits against Happ and is 6 for 12 in his career against him.

Jimenez started in place of the injured Chris Tillman and allowed three runs and nine hits with three strikeouts over 6 2/3 innings.

"After first couple of innings," Jimenez said, "I was able to use my sinker a lot. It was really good, everything was down, and we got a lot of guys hitting ground balls."

The Blue Jays took a 1-0 lead in the second on a two-out, RBI single by Kevin Pillar. Jimenez then retired the next eight batters before allowing another single to Pillar in the fifth.

Pearce tied the game 1-1 with a homer in the bottom half of that inning. Two batters later, Machado drove Happ's 0-1 pitch over the wall in centre field for a two-run homer that gave Baltimore the lead.

THE BIG TEN

The Orioles have three players — Chris Davis, Machado and Mark Trumbo — with at least 10 home runs in August. It's the first time in club history they accomplished that feat.

MOVES

Orioles: RHP Logan Ondrusek and OF Julio Borbon were outrighted to Double-A Bowie. Both players were designated for assignment over the weekend and cleared waivers.

TRAINER'S ROOM

Orioles: CF Adam Jones performed drills but was held out of the lineup for the fourth consecutive game with a left hamstring strain. ... Tillman (right shoulder bursitis) could potentially throw off a mound this weekend. However, the original target dates of Sept. 9 or 10 for his next start appear unlikely, Showalter said.

UP NEXT

Blue Jays: Aaron Sanchez (12-2, 2.99 ERA) will be recalled from Class-A Dunedin to make the start. He spent the past 10 days in the minors to limit his innings. Sanchez has gone 2-0 with a 4.50 ERA in three starts against Baltimore this season.

Orioles: Yovani Gallardo (4-6, 5.59 ERA) has lost his past three decisions. In his last outing against the Yankees, he lasted just 1 1/3 innings, allowing eight runs and six hits.