DENVER — Pete Alonso didn't need a big swing in the ninth inning — just a good eye.

Alonso hit his major league-leading 49th homer, then drew a bases-loaded walk during a four-run rally in the ninth that sent the Mets over the Colorado Rockies 7-4 Wednesday.

The Mets began the day four games behind the Cubs and Brewers for the second NL wild card. After winning two of three at Coors Field, the Mets have 10 games left this season starting with a three-game series in Cincinnati that opens Friday.

"We would've liked to have a sweep at this point, but taking a series is huge for us. We're going to grab as many games as we can and see where the dust settles," Alonso said. "We still have an outside shot."

Alonso hit a long solo home run to left field in the sixth. He moved within three homers for the most by a rookie, a mark set by Aaron Judge with 52 for the Yankees in 2017.

Jeff McNeil also went deep for the Mets, who set a franchise record with 225 home runs this season.

"We've still got some ball left so hopefully we can extend that a little bit," Alonso said.

Trailing 4-3 going into the ninth, the Mets tied it on Brandon Nimmo's third hit, an RBI single off Jairo Diaz (5-4). After a walk to McNeil loaded the bases, Joe Harvey relieved and walked Alonso on four pitches to put the Mets ahead.

"They don't want to have to groove a fastball to him when they fall behind," Mets manager Mickey Callaway said. "He puts the fear in guys and he should because he's a great hitter. That allows him to be a little more patient."

Another run scored on a double-play grounder, and Seth Lugo (7-4) hit an RBI single in his first plate appearance of the season.

Lugo said he was waiting for an at-bat all year but his enthusiasm waned a bit when Harvey's first pitch to Alonso was high and inside.

"I saw him miss around Pete's face and with those shadows I wasn't too comfortable out there the first couple of pitches," Lugo said. "I just didn't want to look dumb. I was staying short and see what happens."

Rookie Sam Hilliard hit two home runs for the last-place Rockies, connecting both times off Noah Syndergaard. Hilliard's first homer went an estimated 447 feet to right-center and his second drive gave the Rockies a 2-1 lead. Hilliard was recalled on Aug. 27 and homered in his debut that night.

"It was a pitch I could handle and those are the ones you're not supposed to miss. I was fortunate enough to get a good swing on it," Hilliard said of his first home run.

Syndergaard went 5 2/3 innings, giving up four runs on 10 hits and striking out six. René Rivera started at catcher — Syndergaard recently expressed his interest in pitching to someone other than regular starter Wilson Ramos.

Ramos pinch-hit for Rivera and drew a leadoff walk in the ninth to begin the Mets' rally.

McNeil hit his 22nd homer, tagging Jeff Hoffman in the first inning. Hoffman allowed two runs and five hits in 5 1/3 innings.

TRAINER'S ROOM

Mets: RHP Robert Gsellman (right triceps tightness) will throw off a mound again, Callaway said. Gsellman was scheduled to play catch Wednesday.

TOUGH ENDING

Diaz moved into the closer's role after Wade Davis was ineffective and Scott Oberg went on the injured list, and he converted his previous four save opportunities before Wednesday's blown chance.

"Unfortunately, we've been here before, so we know how to handle it," third baseman Nolan Arenado said. "Jario has been really good for us but this is one of those hiccups. They had really good at-bats towards the end. You just have to give them credit."