Their ace put them in an early hole, their manager got tossed in the fifth inning, and the Giants lost to the American League-leading Tigers for the second game in a row.

Logan Webb allowed Detroit (36-20) to plate runs in each of the first three innings Tuesday at Comerica Park, and that was more than enough as the Giants’ bats stayed silent in a 3-1 loss.

It required an RBI double from Wilmer Flores in the ninth inning for the Giants (31-24) to avoid being shut out for the second time in five games on this road trip. They need to win Wednesday to avoid being swept in a series of three or more games for only the second time this season.

The team’s frustrations boiled over at the beginning of the bottom of the fifth, when Bob Melvin was ejected by home plate umpire Tony Randazzo for arguing balls and strikes after questionable calls went against the Giants in the top half of the inning and in the Tigers’ first at-bat of the bottom half.

Webb rebounded to complete six innings and struck out 10 batters, but allowed the Giants to fall behind early for his second consecutive start.

Until a week ago, only the Mets’ Kodai Senga had allowed fewer home runs than Webb among qualified starters. He surrendered two in his first 10 starts with a 2.42 ERA. But opponents have taken him deep in each of his past two starts as he allowed nine runs (six earned) on 17 hits in 10 innings, raising his ERA to 2.82.

The Giants lost both games, the first time they have lost consecutive starts of Webb’s all season, dropping their record behind their ace to an even 6-6.When things have gone south for Webb, it has often happened early. Of the 27 runs scored against him this season, 19 have come in the first three innings. The Royals got to him in each of the first two innings in his last start, and the Tigers followed the same pattern on Tuesday.

Riley Greene ripped a 114.5 mph double that scooted away from Mike Yastrzemski in right field, allowing Gleyber Torres to race home and open a 1-0 lead in the first.

Webb fell behind Wenceel Pérez — activated from the 60-day injured list before first pitch — and allowed him to line a 2-0 sinker over the right field wall in his very first at-bat of the season, extending the lead to 2-0 in the second.

Yastrzemski ran into more problems in the third when the leadoff hitter sent a line drive into the right field corner. He gave chase as the ball ricocheted off the wall and around the warning as Colt Keith cruised into third for a leadoff triple.

Greene, the next batter, collected his second RBI in as many at-bats, sending the first pitch over the head of the infielders playing in on the cut of the grass to make it 3-0.