The former closer did it on a day when the Giants celebrated their 2010 World Series championship, a team that had more than its fair share of tight finishes.
Melancon got pinch-hitter Carlos Perez to fly out with the bases loaded in the ninth inning, preserving a 5-3 win over Texas Rangers on Saturday.
"It's really incredible how similar the two games were but we found a way to get the last out today," San Francisco manager Bruce Bochy said. "Torture was back."
San Francisco began the day nine games behind Milwaukee for the second NL wild card.
"It's very important to continue to send that message of relentless attack," Pence said. "Even where we are and as clouded as it may seem, you still never know. When there's still a chance in this game of baseball, things can get hot in an instant."
Hours after Bochy confirmed that six-time All-Star catcher Buster Posey is headed for season-ending hip surgery, San Francisco did the bulk of its scoring in the first inning then held on behind Suarez and three relievers for a rare win at AT&T Park.
Suarez (5-9) struck out five and walked three to win for the first time since July 29. The left-hander induced 12 groundouts and two double plays.
"This whole week I looked at old video just to see what could get me going again," Suarez said. "Once I know I'm getting a lot of groundballs I know that's when I'm in my game."
The Giants have the fourth-best winning percentage in the NL at home but had lost 10 of the previous 13 at their waterfront ballpark before edging the Rangers.
Rougned Odor homered and had three hits for Texas.
"The difference is we didn't get the big hit when we needed to there late," Rangers manager Jeff Banister said. "We felt good about our situation once we got some baserunners there in the last inning. We were unable to come up with the big hit."
Crawford homered off Martin Perez (2-6) in the first, a three-run blast to center. The Giants shortstop entered the day batting .178 since July 1, the lowest average in the majors among players with at least 150 plate appearances.
Pence had a pinch-hit home run off Matt Moore in the seventh.
Odor, who hit a tying two-run home run in the ninth Friday, trimmed the lead to 5-3 with a three-run shot off Hunter Strickland in the eighth. Two batters earlier, a two-out fielding error by left fielder Austin Slater extended the inning.
IN A RUT
Perez allowed four runs in the first inning then yielded only two hits over the next four innings. The lefty, who missed more than two months on the DL because of pain in his right elbow, is winless since April 22.
"The first inning I threw just one bad pitch," Perez said. "After that I shut it down and just tried to get zeroes."
Rangers: IF Hanser Alberto was placed on the disabled list with a right hamstring strain, an injury he suffered Friday in his first game after being called up to take Bartolo Colon's roster spot. Carlos Perez was called up from Triple-A Round Rock. RHP Nick Gardewine was placed on the 60-day DL with a right forearm strain.
Giants: Posey will undergo hip surgery Monday in Colorado and will miss 6-8 months, ending what has been a painful and frustrating year for the six-time All-Star. RHP Jeff Samardzija will seek a second opinion on his troublesome pitching shoulder. Samardzija has been on the DL since July 15.
Rangers RHP Yovani Gallardo (7-2, 6.06 ERA) has six wins in 10 career starts against the Giants. San Francisco LHP Derek Holland (6-8, 3.75), who won 62 games over eight seasons with Texas, makes his third career appearance against his former club.
More AP MLB: https://apnews.com/tag/MLB and https://twitter.com/AP-Sports
Kris Bryant happy to clear the air with Yadier Molina over comments about St. Louis
Cubs third baseman Kris Bryant said he's more than happy to clear the air with Yadier Molina after offseason comments Bryant made about the city of St. Louis raised the ire of the Cardinals' All-Star catcher.
The Pads must be crazy! Why Manny Machado would make no sense for San Diego
You can't blame the Padres for being interested in a superstar in his prime. But the timing just isn't right, the moment isn't right, and the deal would seem destined to fall flat.
Cora: Red Sox in a good place heading into 2019 season
Red Sox manager Alex Cora expresses confidence in his team heading into the 2019 MLB season.
Dodgers' Kenley Jansen hoping higher spin rate will help him sizzle
The Dodgers' closer is aiming to get more movement on his cutter in an attempt to rebound from an erratic 2018.
Who is baseball's real home run king?
We break down the cases for why you might crown Barry Bonds, Hank Aaron or Babe Ruth.
MLB third baseman tiers: Hot corner high on franchise-caliber talent
The third base position is loaded with young All-Stars, including several who have yet to hit their prime years.