The Boston Red Sox got All-Star slugger Kyle Schwarber from the Washington Nationals for a minor league pitcher late Thursday night.

The trade was announced after the AL East-leading Red Sox lost to Toronto 13-1 at Fenway Park. Boston is 1 1/2 games ahead of Tampa Bay.

Schwarber had just finished a historic homer barrage when he strained his right hamstring on July 2. The left-handed hitter has been on the injured list since then, but could be playing again within a couple weeks.

CLICK HERE FOR MORE SPORTS COVERAGE ON FOXNEWS.COM

The 28-year-old outfielder was off to a smashing start in his first season with Washington, hitting 25 home runs with 53 RBIs in 72 games. He was chosen as an All-Star for the first time, but unable to play in the showcase event.

Schwarber tied a major league record by hitting 12 home runs in a 10-game span from June 19-29. He also set a record for a leadoff hitter for homers in a month, connecting 15 times to start games in June.

With Boston, Schwarber could see time in the outfield and also at designated hitter, where J.D. Martinez usually fills the role for the Red Sox.

Schwarber joined the Nationals on a $10 million, one-year contract after six seasons with the Chicago Cubs. In 2016, he played only two games in the regular season after a severe knee injury, then came back to help the Cubs win the World Series by going 7 for 17 (.412) in five games.

The big league trade deadline is 4 p.m. Friday. Earlier Thursday, the Nationals sent closer Brad Hand to Toronto.

The Red Sox sent right-hander Aldo Ramirez to Washington. The 20-year-old Ramirez was 1-1 with a 2.03 ERA in eight starts for Low-A Salem.

To make roster room for Schwarber, the Red Sox designated right-hander Brandon Workman for assignment.

The 32-year-old Workman was a combined 1-2 with a 5.46 ERA in 29 games with the Cubs and Boston this season.