Andrew Knapp hit the winning single in the ninth inning, Bryce Harper hit a tying solo homer in the seventh and the Philadelphia Phillies beat the San Francisco Giants 6-5 on Wednesday.

Harper walked off Wandy Peralta (2-1) to open the ninth, and Brad Miller’s fourth hit of the game put two runners. Knapp hit a one-out single to left, and Harper beat Alex Dickerson's throw him, scoring standing up and touching the plate with his fingertips to help the Phillies avert a three-game sweep against their former manager Gabe Kapler and the Giants.

More Images
Philadelphia Phillies' Mickey Moniak, left, reacts to his three-run home run as San Francisco Giants catcher Buster Posey, right, looks on during the second inning of a baseball game, Wednesday, April 21, 2021, in Philadelphia. (AP PhotoChris Szagola)

Andrew Knapp hit the winning single in the ninth inning, Bryce Harper hit a tying solo homer in the seventh and the Philadelphia Phillies beat the San Francisco Giants 6-5 on Wednesday.

Philadelphia Phillies' Mickey Moniak hits a three-run home run during the second inning of a baseball game against the San Francisco Giants, Wednesday, April 21, 2021, in Philadelphia. (AP PhotoChris Szagola)

Darin Ruf had a pinch-hit, three-run homer in the seventh off Brandon Kintzler and the Giants went ahead 5-4 in the inning after left fielder Andrew McCutchen dropped a routine flyball for an error with two outs. Dickerson drove in Mike Yastrzemski two batters later for the lead. Ruf, a former Phillie, had San Francisco’s seventh pinch hit of the season and third homer.

San Francisco Giants starting pitcher Anthony DeSclafani throws a pitch during the first inning of a baseball game against the Philadelphia Phillies, Wednesday, April 21, 2021, in Philadelphia. (AP PhotoChris Szagola)

Counting Moniak, Phillies center fielders were 4 for 54 with no extra-base hits this season. Moniak ended that extra-base skid when he hit a three-run shot in the second inning -- to the delight of a hungry Phillies fan -- off Anthony DeSciafani for a 3-0 lead.

Philadelphia Phillies ground crew covers the field as a rain delay is called during the third inning of a baseball game against the San Francisco Giants, Wednesday, April 21, 2021, in Philadelphia. (AP PhotoChris Szagola)

TRAINER’S ROOM

Philadelphia Phillies' fans watch the game as the rain falls during the fourth inning of a baseball game against the San Francisco Giants, Wednesday, April 21, 2021, in Philadelphia. (AP PhotoChris Szagola)

Giants: RHP Aaron Sanchez (0-1, 2.45 ERA) gets the start as the Giants return home Thursday for the start of a four-game series against the Marlins. Sanchez has allowed two runs or less in each of his first three starts. LHP Daniel Castano (0-0, 1.80 ERA) starts for the Marlins.

Hector Neris (1-1) struck out two in a scoreless ninth for the win.

Philadelphia Phillies' Mickey Moniak, left, reacts to his three-run home run as San Francisco Giants catcher Buster Posey, right, looks on during the second inning of a baseball game, Wednesday, April 21, 2021, in Philadelphia. (AP PhotoChris Szagola)

Philadelphia Phillies' Mickey Moniak, left, reacts to his three-run home run as San Francisco Giants catcher Buster Posey, right, looks on during the second inning of a baseball game, Wednesday, April 21, 2021, in Philadelphia. (AP PhotoChris Szagola)

Darin Ruf had a pinch-hit, three-run homer in the seventh off Brandon Kintzler and the Giants went ahead 5-4 in the inning after left fielder Andrew McCutchen dropped a routine flyball for an error with two outs. Dickerson drove in Mike Yastrzemski two batters later for the lead. Ruf, a former Phillie, had San Francisco’s seventh pinch hit of the season and third homer.

Harper wasted little time tying the game, hitting a two-out, solo homer off Camilo Doval for his fourth this season.

Mickey Moniak hit his first career home run for the Phillies five years after they made him the No. 1 overall pick in the amateur draft. Moniak entered hitting just .067 since he was called up last week in Philadelphia’s latest attempt to shore up production in center field.

Philadelphia Phillies' Mickey Moniak hits a three-run home run during the second inning of a baseball game against the San Francisco Giants, Wednesday, April 21, 2021, in Philadelphia. (AP PhotoChris Szagola)

Philadelphia Phillies' Mickey Moniak hits a three-run home run during the second inning of a baseball game against the San Francisco Giants, Wednesday, April 21, 2021, in Philadelphia. (AP PhotoChris Szagola)

Counting Moniak, Phillies center fielders were 4 for 54 with no extra-base hits this season. Moniak ended that extra-base skid when he hit a three-run shot in the second inning -- to the delight of a hungry Phillies fan -- off Anthony DeSciafani for a 3-0 lead.

Moniak had just 13 plate appearances over 13 games in 2020 and this season entering Wednesday -- and scuffled in the minors. Moniak doesn’t turn 23 until May and was given a chance this week by manager Joe Girardi to earn the starting spot in center. Roman Quinn and Adam Haseley both struggled and even Moniak was pulled in the top of the seventh for Scott Kingery.

Zach Eflin allowed one run in six innings for the Phillies. The game was interrupted 44-minutes by rain and was played in cold, blustery weather more fitting for old Candlestick Park. The weather had nothing to do with the misplay by the slumping McCutchen, who is hitting .164. Yastrzemski’s ball simply popped out of his glove.

San Francisco Giants starting pitcher Anthony DeSclafani throws a pitch during the first inning of a baseball game against the Philadelphia Phillies, Wednesday, April 21, 2021, in Philadelphia. (AP PhotoChris Szagola)

San Francisco Giants starting pitcher Anthony DeSclafani throws a pitch during the first inning of a baseball game against the Philadelphia Phillies, Wednesday, April 21, 2021, in Philadelphia. (AP PhotoChris Szagola)

TRAINER’S ROOM

Phillies: 2B Jean Segura was placed on the 10-day injured list after he left Tuesday’s game with a right quad strain trying to beat a throw. The Phillies also recalled Kingery and RHP Spencer Howard from Lehigh Valley. RHP Ramón Rosso was optioned to Lehigh Valley.

UP NEXT

Philadelphia Phillies ground crew covers the field as a rain delay is called during the third inning of a baseball game against the San Francisco Giants, Wednesday, April 21, 2021, in Philadelphia. (AP PhotoChris Szagola)

Philadelphia Phillies ground crew covers the field as a rain delay is called during the third inning of a baseball game against the San Francisco Giants, Wednesday, April 21, 2021, in Philadelphia. (AP PhotoChris Szagola)

Giants: RHP Aaron Sanchez (0-1, 2.45 ERA) gets the start as the Giants return home Thursday for the start of a four-game series against the Marlins. Sanchez has allowed two runs or less in each of his first three starts. LHP Daniel Castano (0-0, 1.80 ERA) starts for the Marlins.

Phillies: Open a three-game series in Colorado on Friday. RHP Vince Velasquez (0-0, 9.00 ERA) gets the start for the Phillies.

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

Philadelphia Phillies' fans watch the game as the rain falls during the fourth inning of a baseball game against the San Francisco Giants, Wednesday, April 21, 2021, in Philadelphia. (AP PhotoChris Szagola)

Philadelphia Phillies' fans watch the game as the rain falls during the fourth inning of a baseball game against the San Francisco Giants, Wednesday, April 21, 2021, in Philadelphia. (AP PhotoChris Szagola)