Mike Yastrzemski homered with one out in the bottom of the 12th inning to give the San Francisco Giants a 3-2 victory over the New York Mets on Sunday.

The Giants hadn't had a hit since the fourth when Yastrzemski lofted a full-count pitch from Robert Gsellman (1-2) the other way into the left-center stands. Yastrzemski is the grandson of Hall of Fame slugger Carl Yastrzemski.

More Images
San Francisco Giants' Mike Yastrzemski, right, is congratulated by third base coach Ron Wotus (23) after hitting a solo home run against the New York Mets during the 12th inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

Mike Yastrzemski homered with one out in the bottom of the 12th inning to give the San Francisco Giants a 3-2 victory over the New York Mets on Sunday.

San Francisco Giants' Mike Yastrzemski, center, celebrates after hitting a solo home run against the New York Mets during the 12th inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

Zach Green added two singles in his major league debut for the Giants.

San Francisco Giants players celebrate after Mike Yastrzemski (obscured) hit a solo home run against the New York Mets during the 12th inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

Both teams were frustrated with the strike zone of plate umpire Mark Ripperger.

San Francisco Giants' Buster Posey is hit by a throw from New York Mets pitcher Seth Lugo during the eighth inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

DECENT DEBUT

New York Mets' Pete Alonso carries a bat he broke over his knee after striking out against the San Francisco Giants during the third inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

Before he was ejected, Pillar made another in a long line of defensive gems when he raced in and made a sliding catch on Alonso's short fly ball in the first inning, then jumped to his feet and threw out J.D. Davis attempting to take third. Davis had doubled one batter earlier.

New York Mets pitcher Steven Matz throws to a San Francisco Giants batter during the first inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

GIANTS MOVES

San Francisco Giants pitcher Conner Menez throws to a New York Mets batter during the first inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

UP NEXT

Buster Posey had two hits and scored twice to help the surging Giants (50-50) get back to .500 with their 15th win in 18 games. San Francisco took three of four from New York for its first series win over the Mets since 2014. All three wins came in extra innings.

San Francisco Giants' Mike Yastrzemski, right, is congratulated by third base coach Ron Wotus (23) after hitting a solo home run against the New York Mets during the 12th inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

San Francisco Giants' Mike Yastrzemski, right, is congratulated by third base coach Ron Wotus (23) after hitting a solo home run against the New York Mets during the 12th inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

Zach Green added two singles in his major league debut for the Giants.

Michael Conforto homered into McCovey Cove for the Mets. Amed Rosario also went deep, but New York managed only two hits over the final 10 innings. Todd Frazier struck out swinging four times before reaching on an infield single in the 12th.

Trevor Gott (6-0) retired three batters for the win.

San Francisco Giants' Mike Yastrzemski, center, celebrates after hitting a solo home run against the New York Mets during the 12th inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

San Francisco Giants' Mike Yastrzemski, center, celebrates after hitting a solo home run against the New York Mets during the 12th inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

Both teams were frustrated with the strike zone of plate umpire Mark Ripperger.

Mets rookie slugger Pete Alonso snapped a bat over his leg after striking out swinging. Giants center fielder Kevin Pillar had to be restrained by teammates and was ejected for chirping at Ripperger after grounding out to end the eighth.

Mets starter Steven Matz allowed six hits and two runs in six innings with six strikeouts and one walk. Winless since June 8, Matz retired the last six batters he faced — including the final three by strikeout.

San Francisco Giants players celebrate after Mike Yastrzemski (obscured) hit a solo home run against the New York Mets during the 12th inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

San Francisco Giants players celebrate after Mike Yastrzemski (obscured) hit a solo home run against the New York Mets during the 12th inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

DECENT DEBUT

Giants starter Conner Menez had six strikeouts and allowed three hits and two runs in five innings of his major league debut. The 24-year-old left-hander struck out the side in the third.

SUPERMAN STYLE

San Francisco Giants' Buster Posey is hit by a throw from New York Mets pitcher Seth Lugo during the eighth inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

San Francisco Giants' Buster Posey is hit by a throw from New York Mets pitcher Seth Lugo during the eighth inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

Before he was ejected, Pillar made another in a long line of defensive gems when he raced in and made a sliding catch on Alonso's short fly ball in the first inning, then jumped to his feet and threw out J.D. Davis attempting to take third. Davis had doubled one batter earlier.

DEFENSIVE DOINGS

New York right fielder Jeff McNeil was shaken up when he crashed into the padded right field wall in foul territory after making a running catch on Donovan Solano's deep fly to end the seventh. McNeil slammed into the wall and immediately fell to the dirt before getting up and jogging slowly to the dugout.

New York Mets' Pete Alonso carries a bat he broke over his knee after striking out against the San Francisco Giants during the third inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

New York Mets' Pete Alonso carries a bat he broke over his knee after striking out against the San Francisco Giants during the third inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

GIANTS MOVES

In a series of moves that could be indicative of the direction the team is leaning with the July 31 trade deadline approaching, the Giants brought up Menez and Green from Triple-A Sacramento, while reliever Derek Holland and infielder Ryder Jones were designated for assignment. Menez takes the place of Drew Pomeranz in San Francisco's rotation. LHP Ty Blach was optioned to Sacramento.

Mets: RHP Zack Wheeler (right shoulder fatigue) was scheduled to throw a bullpen before the game, although manager Mickey Callaway was uncertain of the results. Wheeler is eligible to come off the injured list Monday.

New York Mets pitcher Steven Matz throws to a San Francisco Giants batter during the first inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

New York Mets pitcher Steven Matz throws to a San Francisco Giants batter during the first inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

UP NEXT

Mets: Callaway had not announced his rotation for New York's three-game series against San Diego at Citi Field beginning Tuesday night.

Giants: RHP Shaun Anderson (3-2, 4.87 ERA) faces the Chicago Cubs on Monday. Anderson allowed a career-high five earned runs in his most recent start against Colorado on July 17.

San Francisco Giants pitcher Conner Menez throws to a New York Mets batter during the first inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

San Francisco Giants pitcher Conner Menez throws to a New York Mets batter during the first inning of a baseball game in San Francisco, Sunday, July 21, 2019. (AP PhotoJeff Chiu)

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