Rodriguez, playing this year only because he has appealed a four-month suspension, hit his blast in the seventh inning to break a 1-1 tie. It was his seventh home run in an abbreviated season.
He moved into first place on the major league grand slam list, breaking a tie with famed New York slugger Lou Gehrig.
The Yankees won for only the second time in seven games, a stretch that pushed them 3 1/2 games out of a wild card position at the start of the night.
New York loaded the bases on a single, a hit batsman and a walk in the seventh and Rodriguez came through with a two-out blast to right.
Tim Lincecum (10-14) filled the bases before George Kontos served up the home run.
CC Sabathia (14-13) allowed seven hits through seven innings but held the Giants to one run to claim the victory.
Celebrity Breakups and divorces of 2014 [PHOTOS]