AP photo by John Bazemore / Ozzie Albies, right, walks to the dugout with Marcell Ozuna after hitting a home run in the fifth inning of the Atlanta Braves' home game against the Pittsburgh Pirates on Friday night.

ATLANTA — Austin Riley loved being a part of a homer-happy night for the Atlanta Braves.

"When this lineup clicks up and down, it's scary," he said.

Ronald Acuña Jr. hit a grand slam in the second inning off Tyler Anderson, pinch-hitter Ehire Adrianza added another slam in the eighth against position player Wilmer Difo, and the Braves homered seven times in all in a 20-1 rout of the Pittsburgh Pirates on Friday night.

Riley homered twice for his first multihomer game as a major leaguer, and Ozzie Albies, Marcell Ozuna and Dansby Swanson also went deep for the Braves, who became the first team in MLB history to have seven or more homers in a game that included two slams, according to STATS.

"It was awesome," Riley said. "Just seemed like everything clicked offensively. I think it really goes to show what this team is capable of doing. I know things might not seem like they're clicking right now on a daily basis, but it's there, and it's a matter of time."

Pittsburgh tied a 20-1 loss to Brooklyn on Aug. 1, 1890, and a 25-6 loss to Brooklyn on May 20, 1896, for its third-largest margin of defeat, behind a 27-5 loss at Cincinnati on Sept. 12, 1883, and a 20-0 loss to the Milwaukee Brewers on April 22, 2010.

Acuña had five RBIs and gave Atlanta a 5-0 lead with his 14th homer of the season, which tied the Los Angeles Angels' Shohei Ohtani for the MLB lead. Acuña's first career slam came against Pittsburgh's Alex McRae on June 10, 2019.

Difo, a 29-year-old middle infielder in his seventh MLB season, relieved to start the bottom of the eighth with the Pirates trailing 12-0.

Pitching to catcher Jacob Stallings, Difo threw at up to 88 mph, and Adrianza homered on a first-pitch 80 mph offering. Difo allowed three walks and six hits in his one inning, giving up run-scoring singles to Kevan Smith and Guillermo Heredia, Ozuna's RBI double and Riley's sacrifice fly.

Difo left with a 72.00 career ERA.

"I think Stallings summed it up best," Pirates manager Derek Shelton said with a laugh. "Difo didn't have his best stuff tonight, and they capitalized on it."

Atlanta avoided falling what would have been a season-worst five games under .500. The three-time reigning National League East Division champions, who have yet to get above .500 in 2021, had lost seven of their previous 10 games, including a 6-4 loss to the Pirates in 10 inning in Thursday's opener of the four-game series.

Atlanta's Ian Anderson started against Pittsburgh's Tyler Anderson, after Ian Anderson started and won at Milwaukee last Saturday in a game in which the Brewers started Brett Anderson. This marked the first time since 1900 that a pitcher started consecutive games against different pitchers with the same last name as him, according to the Elias Sports Bureau.

Ian Anderson (4-1) gave up six hits in six scoreless innings with six strikeouts and no walks as the Braves won for the seventh time in his past eight starts. He stranded two runners in the first, one runner in the second, one in the fifth and two in the sixth. Two of the hits came on bunts and another was an infield single.

Anderson improved to 3-1 with a 2.45 ERA in eight career home starts. Atlanta starters have combined for a 2.50 ERA over the past 17 games.

Tyler Anderson (3-4) gave up nine runs, 10 hits — seven for extra bases — and two walks in five innings. The Pirates had won five of his previous six starts.

Shelton said it will be easy to move on from such a lopsided loss.

"It's actually easier to move on from a game like this because the games that are 4-1, 4-3, there's situations you look back and think this couldn't have been different," he said. "Tonight we just got beat. You just move on from it and come back tomorrow."

Albies and Riley homered back to back in the fifth for a 9-0 lead, and Riley and Swanson hit consecutive homers in the seventh against Chasen Shreve.

"We've been struggling to score runs and get hits, so that was good to see," Braves manager Brian Snitker said. "There were some good at-bats, going the other way, it was a good night. And the way Ian backed up his last start with how he threw tonight was really good."