Houston’s Jeremy Pena celebrates after scoring in the seventh inning of the Astros’ 6-5 win over the Yankees in Game 4 of the ALCS on Sunday in New York. John Minchillo/Associated Press

NEW YORK — Yordan Alvarez and Alex Bregman delivered big hits and the Houston Astros advanced to the World Series again, finishing a four-game sweep of New York in the AL Championship Series with a 6-5 victory Sunday night aided by another defensive gaffe from the Yankees.

Taking advantage of a costly error by second baseman Gleyber Torres to produce the go-ahead rally in the seventh inning, the Astros won their second consecutive pennant and fourth in six years.

Rookie shortstop Jeremy Peña hit a three-run homer off ailing Yankees starter Nestor Cortes to help the AL West champions overcome an early 3-0 deficit.

Houston will open the World Series at home Friday night against Bryce Harper and the wild-card Philadelphia Phillies, who beat San Diego earlier in the day to close out the best-of-seven NLCS in five games.

It was the first time both pennants were decided on the same day since 1992.

After losing to Atlanta in last year’s World Series, Houston earned the fifth pennant in franchise history and another chance at its second World Series championship.

The team’s 2017 title was tainted by a cheating scandal.