BALTIMORE — Mookie Betts homered twice Tuesday, including a tiebreaking, two-run shot in the top of the eighth inning that gave the Boston Red Sox a 5-3 victory over the Baltimore Orioles.

Boston (66-52) earned its fifth consecutive win and pulled into a tie with Baltimore (66-52) for second place in the American League East. Both teams were a half-game back of Toronto (67-52) pending the Blue Jays’ result later Tuesday against the New York Yankees.

Betts drove in all five Red Sox runs with a three-run homer and the two-run blast. He has hit eight homers against Baltimore this year, and he has three multi-homer efforts at Camden Yards.

He belted three home runs Sunday against the Arizona Diamondbacks, and he is 7-for-13 with five homers and 13 RBIs in the past three games.

The right fielder hit three homers on May 31 and added two more the next day. Also, Betts has eight homers and 22 RBIs in his past 16 games.

His three-run homer in the fifth off starter Yovani Gallardo gave the Red Sox a 3-0 lead as Baltimore remained quiet on offense early.

The Orioles did not get a hit until the seventh, when Steve Pearce reached on an infield single off reliever Matt Barnes. Pearce and Mark Trumbo then scored on Matt Wieters’ two-run single off Fernando Abad two batters later.

Baltimore tied it when Adam Jones drew a bases-loaded walk with two outs later in the inning off Brad Ziegler (1-3). However, Ziegler struck out Jonathan Schoop with the bases loaded to keep the game even and set the stage for the Betts homer off Brad Brach (7-2) in the eighth.

Boston eventually used six pitchers, and Craig Kimbrel closed it in the ninth for his 21st save.

Gallardo gave up three runs on four hits in five innings, all of the runs coming on the Betts homer in the fifth. He walked five, one in each inning, and struck out two while often pitching from behind in the count.

Boston threatened a few times in the early innings but came up empty. The Red Sox left the bases loaded in the third before finally breaking through in the fifth.

Andrew Benintendi led off with a double off the wall in right and Xander Bogaerts drew a one-out walk. Betts then crushed his two-out, three-run homer to left on the first pitch from Gallardo, giving the Red Sox a 3-0 lead.

Boston starter Eduardo Rodriguez breezed through the first four innings, not allowing a hit, but came out because of left hamstring tightness after two pitches in the fifth. Barnes came on to replace him and completed a walk to Pearce before retiring the next three batters.

Rodriguez finished with seven strikeouts and two walks.

NOTES: OF Joey Rickard will have his injured thumb examined Wednesday, and manager Buck Showalter said the Orioles hope he will be cleared to resume baseball activities soon. … Baltimore pitching coach Dave Wallace (personal) needed to go home for three days, which means Dom Chiti takes over his role while Brian Graham will become the bullpen coach. … Manager John Farrell said the Red Sox have had internal discussions about RHP Jonathan Papelbon, who was recently released by Washington. Should Papelbon sign with Boston, Farrell said he would not be a closer. … Farrell also said that INF Hanley Ramirez, presently on the bereavement list, is scheduled to come back to the team on Thursday in Detroit and would miss both games of the brief series in Baltimore.

Royals 6, Tigers 1

DETROIT — Danny Duffy won his ninth straight decision with the aid of four solo home runs, including the first of Raul Mondesi’s career, as the Kansas City Royals defeated the Detroit Tigers 6-1 on Tuesday at Comerica Park.

Duffy (10-1) limited the Tigers to one run on three hits while striking out five in 7 2/3 innings. He has the longest winning streak by a Royals pitcher since Jeremy Guthrie won 10 straight decisions in 2012-13.

The breakthrough homer for the 21-year-old Mondesi came in his 19th game and 60th official at-bat.

Alex Gordon, Eric Hosmer and Kendrys Morales also homered for Kansas City, which has won eight of 10. Gordon, who scored twice, stretched his hitting streak to seven games

Tigers starter Justin Verlander (12-7) allowed five runs — three earned — on four hits while striking out six in seven-plus innings.

Jarrod Saltalamacchia homered for Detroit, which has lost seven of its last nine. Slugger Miguel Cabrera sat out with a left biceps strain.

Hosmer’s 16th home run to straightaway center gave the Royals a 3-1 lead in the seventh.

Sloppy play by the Tigers allowed the Royals to tack on two runs in the eighth. First baseman Saltalamacchia, filling in for Cabrera, failed to catch third baseman Casey McGehee’s low throw on Gordon’s leadoff grounder. Gordon reached second on the play and advanced to third on a single by Alcides Escobar, who reached second on left fielder Justin Upton’s non-chalant relay throw.

A walk loaded the bases and ended Verlander’s night. One out later, Chelsor Cuthbert’s pop fly was dropped by second baseman Ian Kinsler, who then forced Escobar at third as Gordon scored. Lorenzo Cain followed with a run-scoring double for a 5-1 Royals lead.

Morales homered off Mark Lowe in the ninth.

Mondesi drilled an 0-1 pitch just inside the right-field foul pole to put the Royals on top in the third inning. Verlander retired the first eight batters prior to Mondesi’s homer.

Verlander didn’t allow another baserunner until Gordon crunched a 3-1 pitch over the right-field wall with two out in the fifth.

Duffy allowed just one baserunner until Saltalamacchia blasted his 11th home run over the center field wall, also with two out in the fifth.

NOTES: Detroit 1B Miguel Cabrera could return to the lineup as early as Wednesday. His left biceps strain, which forced him to leave Monday’s game, is not considered serious. “If this was the last week of the season, I promise you Miggy would be playing and he’d want to be in there,” manager Brad Ausmus said. … The Tigers acquired INF Erick Aybar from the Atlanta Braves for INF Mike Aviles and minor league catcher Kade Scivicque prior to the game. Aviles was hitting .210 with one home run and six RBIs this season. Detroit also recalled OF Steven Moya from Triple-A Toledo. … Kansas City RHP Wade Davis, who landed on the disabled list on July 31 with a flexor strain, threw 25 pitches in a side session on Tuesday. The team’s closer will throw another side session on Thursday. … Royals RHP Yordano Ventura, who is slated to start Wednesday’s contest, has a 6-0 career record against Detroit.