SAN FRANCISCO — Tony Vitello got ejected just in time to watch his bullpen implode Sunday in the Giants’ 5-2 loss to the New York Mets at Oracle Park.

New York scored four times in the eighth inning against relievers Keaton Winn and Erik Miller, with Vitello watching on a monitor after being ejected in the seventh for protesting a play at first base where Jerar Encarnacion was called out for going out of the base path on an infield grounder.

It was the third straight loss for the Giants, who fell to 3-7 before a home crowd of 37,909. The Mets, winners of three of four in the series, improve to 6-4.

The Mets scored on a two-run double by Luis Torrens, an RBI double by Marcus Semien and on an infield single by Matt Vientos with Matt Chapman contributing a throwing error to erase all the good that Webb did through seven innings.

Winn (0-1) was the losing pitcher, giving up two earned runs, with Miller giving up two more. Huascar Brazoban (1-0) was the winning pitcher with Devin Williams pitching the ninth for his second save. Williams gave off a leadoff single to Chapman — who was thrown out attempting to steal second — but gave up only a harmless single to Heliot Ramos before closing it out.

After six efficient innings, Webb escaped in his most labor-intensive frame in the seventh, finally inducing Francisco Lindor to ground out to second with the bases loaded and two outs.

Jared Young opened the seventh with a fly ball double over the head of Ramos in left. Vientos followed with a solidly struck ball to right center, with Harrison Bader catching it despite getting tangled with left fielder Jung Hoo Lee. That enabled Young to reach third with one out.

Webb struck out Semien and walked Carson Benge before No. 9 hitter Francisco Alvarez reached base on a catcher’s interference on Patrick Bailey to load the bases. Webb then got Lindor with his 24th and final pitch of the inning.

That was it for Webb, who threw 92 pitches — 61 of them strikes — in giving up one run in seven innings. Webb struck out three and walked one, with Winn coming on in the eighth.

In the top of the seventh, Vitello was ejected for the first time in his major league career after disputing the call at first base when Encarnacion appeared to veer out of the base path on a comebacker. Vitello argued with first base umpire David Rackley, who threw him out.

Vitello’s last ejection was at the University of Tennessee last May 4 for arguing check swings against Auburn.

The Giants broke through against Kodai Senga in the sixth with a pair of two-out hits, a screaming double to left by Chapman at 104.8 miles per hour, and a well-placed 75.6 miles per hour bloop single by Rafael Devers that scored Chapman.

Bailey led off the inning for the Giants with a single and stole second with one out Luis Arraez flied to shallow left and Chapman followed with his double.

The Mets scored in the second on the third of three consecutive singles by Luis Robert Jr., Young and Vietos, with Webb getting out of the inning with a ground-ball double play and a fly out.

In the fourth, New York lost an opportunity to score when Young hit a broken-bat single to right, with Robert failing to identify it quickly enough as a hit and leaving a runner at third. Webb got a ground-ball double play to get out of it.

The Giants didn’t get their first hit until Arraez singled to left center to lead off the fourth. He was quickly erased on a double play ball by Chapman. Devers walked, but Ramos followed with an infield out to end the inning.

In the fifth, Encarnacion hit what looked to be a would-be double off the fence in left with one out, except Young erased him at second base with a perfect strike to Semien, who tagged him out.

The Giants begin a three-game series with the Philadelphia Phillies on Monday (6:45 p.m., NBC Sports Bay Area) at Oracle Park.