Mookie Wilson scored from third on an error by first baseman Jason Thompson with none out in the 18th inning, giving host New York the win after nearly 5 1/2 hours.
Gary Carter led off the 18th by walking on four pitches off Lee Tunnell (0-2), the loser and seventh Pittsburgh pitcher. Wilson ran for Carter and advanced to third on a single by Darryl Strawberry, who had a grand slam in the first.
Then, with the outfield drawn in and the infield halfway, Clint Hurdle lashed a shot through Thompson's legs to score Wilson.
Tom Gorman (2-1) got the win after seven innings of relief.
The game lasted 5:21, the longest NL game since Aug. 17, 1982, when Chicago played Los Angeles for 6:10.
The Pirates loaded the bases in the ninth and the Mets in the 12th without scoring.
At one point in the 12th, Pirates Manager Chuck Tanner had his entire team in the infield. Rusty Staub went into the Mets outfield in the 12th, playing right field against right-handed batters and left field against left-handed batters.
Carter, the Mets catcher, had two putouts at home plate and an assist as a runner tried to score after a passed ball. Carter also dove into the stands to make an inning-ending catch on a pop foul with bases loaded in the 14th.