DETROIT (AP) -- Ty Blach took a shutout into the seventh inning, and the San Francisco Giants held off a late Detroit rally in beating the Tigers 5-4 on Wednesday night.
The Giants led 5-0 before Detroit scored four times in the seventh. Blach (6-5) was pulled after allowing a two-run single to Victor Martinez, and San Francisco needed three relievers to get through the inning. The Giants used five relievers in all, with Hunter Strickland pitching the eighth and Sam Dyson finishing for his third save.
The last-place Giants have won seven of their last eight games -- after losing 12 of 13 before that.
Daniel Norris (4-7) permitted five runs and seven hits in four innings.
Blach won his second consecutive start following a rough stretch through the middle of June. The 26-year-old left-hander gave up only three hits in the first six innings against Detroit's lineup of powerful right-handed hitters. Blach was charged with three of the runs in the seventh, but by then, the Giants already had a big enough lead.
San Francisco scored two in the second, and Brandon Belt added an RBI single in the third. Hunter Pence followed with a two-run triple off Norris, who has lost his last three starts.
The Giants nearly gave the whole lead away in the seventh. Miguel Cabrera singled to start the rally, and J.D. Martinez followed with a double. Victor Martinez's single made it 5-2, and George Kontos allowed a single to Mikie Mahtook.
Steven Okert struck out pinch-hitter Alex Avila, but Cory Gearrin came on and walked Jose Iglesias. With the bases loaded, Ian Kinsler hit a comebacker that bounced off Gearrin for a run-scoring single. A sacrifice fly by Nicholas Castellanos made it 5-4, but Justin Upton struck out to end the inning.
San Francisco leadoff man Gorkys Hernandez had three hits.
Detroit activated OF Alex Presley from the seven-day concussion DL and designated OF Matt den Dekker for assignment. The Tigers also activated OF Jim Adduci from the seven-day DL and optioned him to Triple-A Toledo.
Detroit agreed to terms with first-round draft pick Alex Faedo, a right-hander who pitched at Florida.
Giants: LHP Madison Bumgarner (ribs, shoulder) was scheduled to make a rehab start for Class A San Jose, and 3B Conor Gillaspie (back) was expected to play in the same game.
Tigers: Cabrera, who left Tuesday's game with left hip tightness, was in the starting lineup and had two hits.
Giants: RHP Johnny Cueto (6-7) takes the mound in the series finale.
Tigers: RHP Anibal Sanchez (0-0) tries for his third consecutive quality start.