Manny Machado hit a two-run home run — his first in more than three weeks — and left-hander Joey Lucchesi pitched five decent innings for the San Diego Padres, who beat the Boston Red Sox 3-1 Sunday to avoid a three-game sweep.

Machado, the $300 million slugger, drove a pitch from left-hander Brian Johnson for his 27th homer to give the Padres a 3-0 lead. It was the third straight hit off Johnson to open the inning. Manuel Margot hit a leadoff double and scored on Francisco Mejia's single.

Machado hadn't connected since July 30 in a home loss to his original team, the Baltimore Orioles.

San Diego Padres' Manny Machado, right, reacts with third base coach Glenn Hoffman after hitting a two-run home run during the first inning of a baseball game against the Boston Red Sox Sunday, Aug. 25, 2019, in San Diego. (AP PhotoGregory Bull)

San Diego Padres' Manny Machado, right, reacts with third base coach Glenn Hoffman after hitting a two-run home run during the first inning of a baseball game against the Boston Red Sox Sunday, Aug. 25, 2019, in San Diego. (AP PhotoGregory Bull)

It was the Padres' 190th homer of the season, setting the franchise's season record.

Lucchesi (9-7) allowed one run and three hits in five innings, struck out three and walked two.

His only big mistake was allowing J.D. Martinez's 411-foot home run into the top balcony of the Western Metal Supply Co. Building in the left-field corner for Boston's first hit of the game with two outs in the fourth. It was his 31st.

San Diego Padres' Eric Hosmer, left, is tagged out at home by Boston Red Sox catcher Christian Vazquez during the third inning of a baseball game Sunday, Aug. 25, 2019, in San Diego. (AP PhotoGregory Bull)

San Diego Padres' Eric Hosmer, left, is tagged out at home by Boston Red Sox catcher Christian Vazquez during the third inning of a baseball game Sunday, Aug. 25, 2019, in San Diego. (AP PhotoGregory Bull)

In the previous inning, Martinez tracked down rookie Ty France's double into the left field corner and threw to shortstop Xander Bogaerts, who nailed Eric Hosmer trying to score from first to end the frame.

Rookie Andres Muñoz struck out Martinez with runners on the corners to end the eighth.

Kirby Yates bounced back after taking the loss Saturday night, pitching a perfect ninth for his major league-leading 37th save in 40 chances.

Boston Red Sox starting pitcher Brian Johnson works against a San Diego Padres batter during the second inning of a baseball game Sunday, Aug. 25, 2019, in San Diego. (AP PhotoGregory Bull)

Boston Red Sox starting pitcher Brian Johnson works against a San Diego Padres batter during the second inning of a baseball game Sunday, Aug. 25, 2019, in San Diego. (AP PhotoGregory Bull)

Boston starter Brian Johnson (1-3) lasted only three innings, allowing three runs and four hits while walking three and striking out one.

NICE CATCH

Boston's Jackie Bradley Jr. made a spectacular leaping catch of Luis Urias fly ball at the top of the wall in center field opening the fourth.

WIPEOUT

Margot tripped after rounding second on what looked to be a sure triple, had one of his orange cleats blow apart and was tagged out.

UP NEXT

Red Sox: RHP Rick Porcello (11-10, 5.49) is scheduled to start Tuesday night in the opener of a two-game series at Colorado.

Padres: LHP Eric Lauer (6-8, 4.47) is scheduled to start Monday night in the opener of a three-game series against the Los Angeles Dodgers, the runaway NL West leaders. The Dodgers are expected to counter with rookie RHP Dustin May (1-2, 4.26).

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