Updated

Nick Castellanos homered and tripled, and the Detroit Tigers rallied for an 8-4 victory over the Pittsburgh Pirates on Wednesday night, snapping a four-game losing streak.

The Tigers, who are suddenly facing adversity amid mounting injuries, rallied from a 4-1 deficit on a night when they had to send Buck Farmer to the mound to make his major league debut.

Farmer allowed four runs in five innings, and Blaine Hardy (2-1) followed with two scoreless innings of relief.

Castellanos put Detroit ahead 5-4 with a solo homer off Vance Worley (5-2) in the sixth. Victor Martinez added a two-run single in the seventh.

The Tigers returned home after going 2-7 on a road trip against the New York Yankees, Toronto and Pittsburgh. A 19-inning loss to the Blue Jays stretched the pitching staff thin, and Anibal Sanchez and Justin Verlander are nursing injuries.

It was tied at 1 in the fourth when Pittsburgh's Jordy Mercer hit an RBI triple and Travis Snider followed with a two-run homer. The Tigers tied it with three runs in the fifth.

Avila led off with a homer to make it 4-2, and after a single by Eugenio Suarez, Ezequiel Carrera hit a grounder to second. Jayson Nix tried to make a tough throw to second to get the lead runner, but his throw was poor, and the error helped Detroit to a big inning. Miguel Cabrera eventually hit a sacrifice fly, and Martinez tied it with a two-out RBI single.

Castellanos hit his ninth homer of the year with one out in the sixth.

Worley allowed five runs — three earned — and nine hits in 5 1-3 innings.

TRAINER'S ROOM

Pirates: Pittsburgh was once again without 2B Neil Walker, who has been limited to only three games this month. Walker has been bothered by a bad back.

Tigers: Detroit 2B Ian Kinsler stayed in the game and seemed to be OK after a pitch by Stolmy Pimentel bounced weirdly and hit him in the side of the head. Pimentel's pitch in the seventh inning was in the dirt, then bounced up off C Russell Martin and hit Kinsler.

UP NEXT

Pirates: Francisco Liriano (3-8) takes the mound for Pittsburgh on Thursday against Detroit. He's posted a 2.25 ERA in five starts since returning from a left oblique strain.

Tigers: Max Scherzer (13-4) pitches for the first time since striking out 11 in eight innings against Toronto on Saturday — in a game Detroit went on to lose in 10.