NEW YORK (AP) Giants Gold Glove shortstop Brandon Crawford made three errors for the first time in his career, with his wild throw in the eighth inning giving the New York Yankees a 3-2 win Friday night that sent San Francisco to its season-worst sixth straight loss.

The Giants held the best record in the majors at the All-Star break, but haven't won since. They also lost catcher Buster Posey, who fouled a ball off his right foot and left with a bruise. X-rays were negative and he was listed as day to day.

Masahiro Tanaka shut out San Francisco for six innings, giving up four singles. Giants ace Madison Bumgarner went seven innings, allowing two runs.

More from FoxSports

The Giants nicked Dellin Betances in the seventh, pulling within 2-1 on a walk, a double by Denard Span and a wild pitch. That ended a streak of 31 scoreless innings by Yankees relievers.

A double by Giants pinch-hitter Mac Williamson off Andrew Miller (6-1) tied it in the eighth.

But the Yankees bounced back for the fifth win in six games, and didn't need to hit the ball hard to do it.

Chase Headley opened the eighth with a swinging bunt for a single off Josh Osich (1-2) and Mark Teixeira walked. Austin Romine followed with a grounder to Crawford, who tagged second, spun around and made a hard, high throw that glanced off the glove of first baseman Brandon Belt.

Headley kept running and beat Belt's throw home. Crawford won his first Gold Glove last season.

Aroldis Chapman closed in the ninth for his 20th save in 21 chances. He worked around a leadoff double by Gregor Blanco.

A spirited crowd of 45,304 also included lots of Giants fans, and the rival rooters spent much of the game loudly cheering, often at the same time. There was a truce when a marriage proposal was shown on the scoreboard in-between innings - he wore a Giants hat, she wore a Yankees cap and said yes to a ring.

Carlos Beltran hit an RBI single for New York and also contributed on defense. The 39-year-old right fielder unleashed a perfect throw home to nail Blanco and later made a running grab to rob Crawford of extra bases.

Starlin Castro got three hits, making him 14 for 27 (.519) against Bumgarner.

TRAINER'S ROOM

Giants: OF Hunter Pence (hamstring) was set to play for Triple-A Sacramento, but INF Joe Panik (concussion) was out of the lineup for the second straight day.

Yankees: SS Didi Gregorius didn't start, but entered as a defensive replacement. Manager Joe Girardi said he wanted to give him a break, and that it might be the last time he sits for a while.

UP NEXT

Giants: RHP Jeff Samardzija (9-5, 4.05) walked a season-high four in his last start vs. San Diego. He is 0-1 with a 6.92 ERA in three career games against the Yankees.

Yankees: RHP Ivan Nova (7-5, 4.92) pitched a shutout in 2013 in his only career start vs. the Giants. He has won his last two starts overall.