Rafael Devers led off the 10th inning with a home run after Marco Hernandez tied it with a solo shot in ninth, and the Boston Red Sox beat the Baltimore Orioles 8-6 Sunday to move a season-high five games over .500.

After winning the first two games of the series in blowout fashion, the Red Sox used some late heroics to complete the sweep and extend their winning streak to five.

Boston trailed 3-2 in the ninth before Hernandez connected off Mychal Givens, who avoided further damage by getting two straight strikeouts following a triple by Mookie Betts.

Boston Red Sox's Brian Johnson throws against the Baltimore Orioles in the first inning of a baseball game Sunday, June 16, 2019, in Baltimore. (AP PhotoGail Burton)

Boston Red Sox's Brian Johnson throws against the Baltimore Orioles in the first inning of a baseball game Sunday, June 16, 2019, in Baltimore. (AP PhotoGail Burton)

In the 10th, however, Givens (0-4) served up a 1-0 pitch that Devers slammed far over the center-field wall. Betts and Christian Vazquez added two-out, two-run singles off David Hess.

Brandon Workman (5-1) worked the ninth for the Red Sox. Boston's eighth pitcher, Josh Smith, gave up a two-run homer to Stevie Wilkerson and a bases-empty drive to Trey Mancini in the 10th.

The Red Sox opened defense of their World Series title by losing their first four games this season and were 9-15 on April 23. Now they're 39-34 and within striking distance of the first-place Yankees in the AL East.

Boston Red Sox's Rafael Devers smiles as he scores on a double by Xander Bogaerts against the Baltimore Orioles in the fourth inning of a baseball game Sunday, June 16, 2019, in Baltimore. (AP PhotoGail Burton)

Boston Red Sox's Rafael Devers smiles as he scores on a double by Xander Bogaerts against the Baltimore Orioles in the fourth inning of a baseball game Sunday, June 16, 2019, in Baltimore. (AP PhotoGail Burton)

Orioles manager Brandon Hyde was ejected in the fourth inning after arguing a call that cost Baltimore a run. Keon Broxton was called out for running in the baseline after laying down a successful squeeze bunt, which by rule sent Anthony Santander back to third base. Richie Martin subsequently struck out to end the inning, leaving the Orioles down 2-1.

The score stayed that way until the eighth.

Baltimore was 1 for 13 with runners in scoring position when Jonathan Villar drew a leadoff walk from Marcus Walden. Villar stole second, then stole third as Chris Davis expressed his displeasure over a called third strike and Vazquez looped his throw from behind the plate to the mound.

Baltimore Orioles manager Brandon Hyde, center, argues with first base umpire Bruce Dreckman, left, and Tripp Gibson after being ejected in the fourth inning of a baseball game against the Boston Red Sox, Sunday, June 16, 2019, in Baltimore. (AP PhotoGail Burton)

Baltimore Orioles manager Brandon Hyde, center, argues with first base umpire Bruce Dreckman, left, and Tripp Gibson after being ejected in the fourth inning of a baseball game against the Boston Red Sox, Sunday, June 16, 2019, in Baltimore. (AP PhotoGail Burton)

Villar scored on a wild pitch before Wilkerson greeted right-hander Travis Lakins with a pinch-hit triple and came home on a single by Hanser Alberto.

The lead didn't last long.

Baltimore has lost five straight, is 9-28 at home and owns the worst record in the majors (21-50).

Boston Red Sox's Mookie Betts singles against the Baltimore Orioles in the first inning of a baseball game Sunday, June 16, 2019, in Baltimore. (AP PhotoGail Burton)

Boston Red Sox's Mookie Betts singles against the Baltimore Orioles in the first inning of a baseball game Sunday, June 16, 2019, in Baltimore. (AP PhotoGail Burton)

NO PANIC

Fans concerned about Boston's position in the playoff hunt probably have a short memory, according to Red Sox manager Alex Cora.

"People forget that we were in second place last year on June 20-something," he said before Sunday's game. "We're in third place. I know where we're at, but we'll be fine."

TRAINER'S ROOM

Red Sox: Andrew Benintendi sat out the game with a sore quad. "Nothing serious," Cora said. ... 1B Steve Pearce (back) emerged unscathed from his first two rehabilitation games. "He felt good, moving around well. At the plate, he feels a lot better," Cora said.

Orioles: Dwight Smith Jr. (7-day concussion protocol) is "progressing very, very well" but will likely need to play a couple of rehab games before returning, Hyde said. ... RHP Alex Cobb is on the mend after undergoing successful season-ending hip surgery.

UP NEXT

Red Sox: Rick Porcello (4-6, 4.69 ERA) helps Boston open a three-game series on Monday night against the host Minnesota Twins, who lead the AL Central.

Orioles: Andrew Cashner (6-2, 4.73) hopes a lingering blister won't be a problem when he faces the Oakland Athletics on the road Monday night. The right-hander missed his scheduled start Friday night.

More AP MLB: https://apnews.com/MLB and https://twitter.com/AP_Sports