Detroit, MI (SportsNetwork.com) - Nick Castellanos finished with four RBI and clubbed a go-ahead three-run triple in the eighth inning, lifting the Detroit Tigers to a 5-2 win over the Milwaukee Brewers in the finale of a three-game set on Wednesday.

Yoenis Cespedes went 3-for-3 with two runs scored and J.D. Martinez supplied two hits and scored twice for the Tigers, who ended a three-game skid.

Blaine Hardy (2-0) earned the win after recording the final out of the eighth. Starter Shane Greene gave up two runs on three hits with six strikeouts over 6 1/3 frames.

Ryan Braun hit a solo home run and Elian Herrera also brought in a run for the Brewers, who were denied their first series sweep of the season.

"I thought we played a good game," said Brewers manager Craig Counsell. "We just didn't have many opportunities."

In the eighth, Martinez and Cespedes each hit singles off Jonathan Broxton (1-1) with two outs to place runners at the corners and Tyler Collins walked to load the bases. Castellanos sliced a liner down the right-field line into the corner, clearing the bags for a 5-2 game.

Joakim Soria worked around a leadoff double to earn his 13th save of the season.

"It's always fun to win and it's always good to come back," said Soria. "This win is very important for us."

Cespedes opened the second with a ground-rule double, stole third and scored after Brewers catcher Martin Maldonado's pick-off attempt sailed into left field.

Braun tied the game in the fourth by leading off with a solo shot into the left-field seats.

The Tigers reclaimed the lead in the home half. Martinez, Cespedes and Collins each singled to load the bases with no outs. Martinez scored after Castellanos hit into a fielder's choice to give Detroit a 2-1 edge, but James McCann hit into a double play to end the threat.

Khris Davis worked a one-out walk in the seventh, Luis Sardinas singled and Herrera tied the game with a double to right.

Game Notes

Tigers second baseman Ian Kinsler recorded his 300th career double ... Martinez extended his hitting streak to 11 games, while Cabrera lengthened his to eight ... Brewers starter Kyle Lohse allowed two runs on seven hits over six frames ... Castellanos tallied four RBI for the second time in his career, also doing so on July 30, 2014, against the White Sox.