Andrew McCutchen gave the Pirates the lead in the seventh with a two-run homer, putting Pittsburgh in position to pick up a crucial decision in the National League Central pennant race.
Pittsburgh closer Mark Malancon then blew a save opportunity, sending the Pirates to their third straight loss. They opened the night a game behind St. Louis in the chase for the division crown.
Jedd Gyroko began the ninth with a single off Melancon (2-2), who then retired the next two men he faced.
Andrew Cashner was called on to run for Gyroko and moved to second on a base hit by pinch-hitter Chris Denorfia. Forsythe and Rivera followed with run-scoring singles to wipe out the Pittsburgh lead.
The San Diego comeback spoiled an outstanding effort by Charlie Morton, who held the Padres to two hits with nine strikeouts over eight innings.
Dale Thayer (3-5) earned the victory by recording the final two outs in the eighth. Huston Street was perfect in the ninth while picking up his 31st save.
Jordana Brewster on Paul Walker: 'He was an enormous presence in my life'
Benedict Cumberbatch's dramatic reading of R. Kelly lyrics is just what you need