NEW YORK (AP) — Jake McGee induced a game-ending popup from Pete Alonso with the bases loaded, and the San Francisco Giants turned five double plays to beat the freefalling New York Mets 3-2 Wednesday night.

Brandon Crawford hit a go-ahead, two-run double in the seventh inning after New York manager Luis Rojas gave starter Taijuan Walker an aggressive hook, and the Giants improved to 4-1 against the Mets over the past 10 days.

READ MORE: Memorial Service For Fallen Marine Sgt. Nicole Gee Held In Roseville

The Mets had two on against McGee in the ninth after Giants outfielders Austin Slater and Alex Dickerson bumped into each other and dropped a one-out fly ball. Francisco Lindor popped up for the second out before Brandon Nimmo drew a full-count walk to load the bases for Alonso.

McGee jammed Alonso with a 1-2 fastball and his soft flare was caught easily on the infield by second baseman Tommy La Stella. It was McGee’s 29th save.

Walker (7-9) overpowered San Francisco through six innings but was pulled in the seventh with 74 pitches after runners reached on an error by third baseman Jonathan Villar and a popup that fell between three Mets defenders in shallow center.

Rojas tabbed left-hander Aaron Loup to face the lefty-hitting Crawford, and the veteran drilled the first pitch to the wall in right for a two-run double and a 3-2 lead. It was one of only four hits for the Giants in the game.

Fans booed Rojas as he made the change and chanted “Fire Rojas!” after it backfired. It was the first extra-base hit Loup had allowed to a left-handed hitter in 70 plate appearances this season.

The Giants have won 21 of 28 as they try to hold off the Dodgers for the best record in the NL West and the majors. San Francisco led Los Angeles by 2 1/2 games entering Wednesday.

New York lost for the 10th time in 12 games — all against the Dodgers and Giants. After leading the NL East for nearly three months, the Mets entered the day 6 1/2 games behind the division-leading Braves.

The five double plays were a season high for New York. Javier Báez ran into the first one when he took off from second on Villar’s liner to center. The ball was caught, and Báez was doubled up easily. Alonso grounded into two double plays, Báez lined into another and Patrick Mazeika also bounced into one.

Walker was perfect until Kris Bryant’s solo homer with two outs in the fourth. The right-hander was charged with three runs (two earned), two hits and a walk over six innings while striking out three. Walker entered the day with a 7.49 ERA in seven starts since making his first All-Star team in July.

The Mets got an unearned run against Johnny Cueto when third baseman Bryant threw away a two-out, bases-loaded grounder hit by slow-footed Alonso to tie it at 1 in the fifth. An inning later, Dominic Smith ripped a go-ahead RBI double off left-hander Tony Watson (5-3).

Cueto was activated from the injured list and pitched for the first time since Aug. 9 due to a right flexor strain. He allowed an unearned run over 4 2/3 innings, giving up five hits and three walks with two strikeouts.

READ MORE: Suspect Armed With An Ax Arrested In Stockton

Alonso singled in the first inning for the first 10-game hitting streak of his career.

SWITCHED UP

Walker lined singles in his first two at-bats, his first hits since switching from hitting righty to lefty a few weeks ago. Walker, a promising right-handed hitter in high school, made the change after experiencing pain in his left shoulder while swinging from the right side.

ARMING UP

Jacob deGrom played catch for the first time in four weeks after an MRI showed improvement with the right forearm tightness that has sidelined him since July 7. Mets teammate Noah Syndergaard will begin a minor league rehab assignment with High-A Brooklyn on Thursday.

The Mets haven’t laid out a progression for deGrom, who is out until at least Sept. 13 because he was placed on the 60-day injured list.

Syndergaard was slated to throw one inning for the Cyclones in his first game action since May, when his first rehab assignment following Tommy John surgery in 2020 was shut down due to elbow discomfort.

TRAINER’S ROOM

Giants: C Buster Posey was out of the lineup a night after leaving the game with left knee discomfort, but manager Gabe Kapler didn’t expect Posey to miss much time. … Crawford was in the starting lineup after leaving Tuesday’s game with lower back tightness. … 1B Brandon Belt will leave the team to attend his grandmother’s funeral Friday in Texas.

Mets: Lindor was out of the lineup a night after ending a five-week absence with a right oblique strain. He struck out as a pinch hitter in the seventh.

UP NEXT

MORE NEWS: Antelope Woman's Stolen Cotton Candy Trailer Located In Rio Linda

Giants LHP Alex Wood (10-4, 4.11 ERA) pitches the series finale Thursday night against Mets RHP Carlos Carrasco (0-2, 8.82).