WASHINGTON — Brandon Belt’s homer off Tanner Roark to lead off the 18th inning lifted San Francisco to its 10th consecutive postseason victory, edging Washington 2-1 Saturday night for a 2-0 lead in their National League Division Series.

It tied the mark for most innings in a postseason game and, as late afternoon stretched into early evening and even past midnight, set a time record at 6 hours, 23 minutes. The teams combined to use 17 pitchers and 24 position players.

The Giants can close out the best-of-five NLDS at home Monday in Game 3, with Madison Bumgarner facing Doug Fister.

The Nationals won the NL East and led the league with 96 wins. But after a pair of one-run losses, they’re looking as if they’re the latest team that can’t figure out how to get past San Francisco.

Down to their final out Saturday while trailing 1-0 in the ninth, the Giants tied it on Pablo Sandoval’s RBI double, then saw Nationals manager Matt Williams and second baseman Asdrubal Cabrera ejected in the 10th.

Yusmeiro Petit entered in the 12th and threw six scoreless innings, allowing one hit and striking out seven, to earn the win. Hunter Strickland got the save with a scoreless 18th.

Roark, Washington’s ninth pitcher, came on in the 17th. An inning later, he threw a 94 mph fastball on a full count to Belt, who drove the ball into the second deck beyond right field.

Only one other postseason game in baseball history lasted 18 innings — when the Astros beat the Braves 7-6 in a 2005 NLDS. That one held the previous record for most time, too, at 5:50. Tim Hudson started that game for Atlanta — he was the Giants’ starter in this one.

Washington had three of its best hitters — Denard Span, Adam LaRoche and Bryce Harper — go a combined 0 for 21.

The Nationals went ahead 1-0 in the third when Anthony Rendon drove in a run off Hudson with one of his four singles.

Jordan Zimmermann gave up three hits through eight shutout innings for Washington.