It took 6 hours, 7 minutes to finish. Both teams scored a run in the 17th, and each club used eight pitchers.
Wandy Rodriguez (8-12), who was set to start for the Pirates on Monday night at San Diego, got the win with two scoreless innings of relief.
About 9,000 fans from the original crowd of more than 43,000 stayed until the end. This was the longest game by innings in the big leagues this year. At 6:07, it tied for the longest by time, matching a game between Baltimore and Boston on May 6.
Each team had played a marathon in recent years. St. Louis went 20 innings against the Mets on April 17, 2010, and Pittsburgh played 19 innings at Atlanta on July 26, 2011.
Houston dropped its fourth straight and fell to 7-33 in its last 40 games.
Arizona won its ninth in a row against the Astros.
Hill, who connected for a three-run homer on Saturday night, kept going deep. He led off a five-run fourth with a shot off Armando Galarraga (0-4) and added another solo homer in the eighth. Hill also doubled.
Ian Kennedy (11-10) went six innings.
NATIONALS 5, METS 2