Pettitte (10-11), making his last scheduled start in New York after announcing his upcoming retirement, had allowed just one run on one hit over six innings.
The score was tied 1-1 when he allowed a leadoff double to Pablo Sandoval in the seventh. Pettitte left the field to a standing ovation and was greeted by longtime teammate and injured captain Derek Jeter before reaching the dugout.
But the likely future Hall of Famer wasn't fated to get the win as reliever David Robertson yielded a two-bagger to Abreu, easily scoring pinch-runner Nick Noonan.
The similarly retiring Mariano Rivera, who was honored in a pre-game ceremony, recorded five outs in the loss.
Ehire Adrianza socked his first major-league homer and Javier Lopez (4-2) picked up the win for the Giants, who avoided a three-game interleague sweep.
San Francisco starter Yusmeiro Petit allowed one run on six hits through 6 1/3 innings, striking out seven.