NEW YORK (AP) - Mac Williamson had crossed paths with Ivan Nova before.
"Fun fact about Nova. I had TJ the same day he did," the San Francisco Giants rookie said, thinking back to their visit to Dr. James Andrews for Tommy John surgery on April 29, 2014. "How many guys face each other after you have surgery, the same day, the same surgeon? That's kind of cool."
Williamson started the comeback with a home run off Nova leading off the fifth inning, then hit a tiebreaking single in the 12th that lifted San Francisco over the New York Yankees 2-1 on Saturday to give the relieved Giants their first victory since the All-Star break.
"I think every good team goes through a little lull at some point in the season," Williamson said.
NL West-leading San Francisco had lost a season-high six straight games and had held just one lead in 57 innings following the break: when Buster Posey hit a go-ahead home run leading off the 10th inning at San Diego on July 16 only to have the Padres rally for a pair of runs in the bottom half against Santiago Casilla.
A 46th-round draft pick in 2011, Williamson had allowed the Yankees to go ahead in the fourth. With Didi Gregorius on first, Mark Teixeira singled to right against Johnny Cueto, and Williamson allowed the ball to kick off his glove for an error that let Gregorius come home.
"I really was upset with myself," Williamson said. "I rushed the play down the line there trying to keep the double play in order there for Cueto."
His sixth home run this season came on a flat sinker and was just his second in 29 at-bats against right-handers. Even before the error, Williamson was peeved because he was thrown out at the plate in the second when he tried to score on Ramiro Pena's double.
New York's No Runs DMC trio of Andrew Miller, Aroldis Chapman and Dellin Betances held the Giants scoreless for four innings before Trevor Brown hit an opposite-field double to right off Anthony Swarzak (1-1) leading off the 12th. Williamson singled up the middle with one out, just past the glove of diving Gregorius at shortstop. San Francisco had been 0 for 10 with runners in scoring position, dropping to 7 for 63 (.111) since the All-Star break.
"We're not getting that timely hit, but we finally did tonight — it is night now, isn't it?" Giants manager Bruce Bochy said after the 4-hour, 25-minute game.
Bochy was impressed that Williamson didn't let his error get him down.
"He put that behind him. He didn't let it bother him," Bochy said. "That's what you have to be in this game: resilient.".
San Francisco had joined the 1991 Los Angeles Dodgers as the only teams to enter the break in first place, then lose its first six games of the second half, according to the Elias Sports Bureau. And after making four errors in the series opener, San Francisco had two more.
Jeff Samardzija had been listed as San Francisco's starter, but Bochy said his intent all along was to start Cueto and attributed the mixup to a failure to inform his media relations staff.
In a late-afternoon start on a 93-degree day, Cueto struggled with deep counts but allowed just the unearned run and six hits in six innings. He struck out nine — including five in a row — and threw 117 pitches, two shy of his season high.
Cheered on by hundreds of orange-clad fans in the Giants' old hometown, San Francisco escaped a bases-loaded, one-out jam in the 10th when Casilla (2-3) retired Brian McCann on a shallow flyout and Starlin Castro on a foulout. Hunter Strickland pitched a perfect 12th for his second save.
Casilla has heard the rumors the Giants are seeking to trade for a closer with a high-strikeout ratio.
"At first it would bother me. I've been doing the job," he said through a translator. "I have a lot of experience during the regular season, the playoffs. I have three World Series rings and I have shown that I can do the job."
NOT SO SIMPLE
With Angel Pagan on third in the 11th, McCann signaled for an intentional walk to Brandon Crawford, and Betances threw the ball to the screen. But Pagan, held closely at third by Chase Headley, decided to stay, and Crawford hit an inning-ending grounder.
San Francisco leads the majors with 30 come-from-behind wins.
Giants: OF Hunter Pence (hamstring) was to play six innings Saturday for Triple-A Sacramento, seven innings Sunday and then take a day off. ... INF Joe Panik (concussion), who hasn't played for the Giants since June 27, played for Sacramento on Tuesday and Wednesday but is sidelined again for a couple more days. ... INF Matt Duffy, out since June 19 because of a strained left Achilles tendon, is running 60-yard sprints at 75 percent. ... RHP Cory Gearrin, who hadn't played since July 5 because of a strained right shoulder, is to pitch to hitters Sunday.
Samardzija (9-5) faces Nathan Eovaldi (8-6) on Sunday.