SAN FRANCISCO — 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 Mets on Sunday.

The Giants had not 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 the Hall of Fame slugger Carl Yastrzemski.

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 the Mets for its first series win over them since 2014. All three wins came in extra innings.

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 the Mets 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.