Jhonny Peralta hit two homers in his first game since being traded and the struggling Detroit Tigers withstood a grand slam by David Ortiz in the ninth inning and beat the Boston Red Sox 6-5 on Friday night.

Peralta, obtained from the Cleveland Indians on Wednesday, hit a solo homer in his first at bat in the second inning then connected again off Jon Lester, a two-run shot in the fifth.

Detroit took a 6-1 lead into the ninth and Jose Valverde struck out leadoff hitter Eric Patterson. Then he walked the next three batters and Ortiz connected for his 22nd homer, just clearing the low fence in right field. With two outs, Adrian Beltre doubled and J.D. Drew was walked intentionally before Mike Cameron took a called third strike.

The Tigers, just 4-12 since the All-Star break, acquired Peralta for left-hander Giovanni Soto to play third base after Brandon Inge went on the disabled list with a broken left hand. Peralta has nine homers this season, none in his last eight games with Cleveland and two in his last 23.

Armando Galarraga lost a chance for the win when he was struck on the outside of the right ankle by a liner from Kevin Youkilis with two outs in the fifth and Detroit leading 4-1. He left with a bruise and was replaced by Enrique Gonzalez, who got the final out of the inning.

Robbie Weinhardt (1-1) was awarded the victory after allowing no runs in the next two innings.

The Red Sox lost the opener of a seven-game homestand after sweeping a three-game series against the Los Angeles Angels to end their West Coast swing at 6-4.

Lester (11-6) fell behind quickly and lost his third straight start. Austin Jackson led off the game with a single and scored on a double By Will Rhymes that bounced off the glove of Cameron as he ran to deep left-center field. Peralta's homer to left made it 2-0 in the second.

His second shot over the left-field wall following a single by Miguel Cabrera put the Tigers ahead 4-0.

Marco Scutaro hit his seventh homer of the season for Boston to cut the lead to 4-1 with one out in the fifth. One out later, Youkilis ripped a pitch off Galarraga's ankle and got a single as the ball bounced toward the left-field line. Galarraga went down on the mound and manager Jim Leyland and a trainer went out to check on him.

After staying on the ground for about five minutes, Galarraga got up and walked slowly to his dugout. Gonzalez then walked Ortiz and threw a wild pitch, putting runners on second and third, then retired Victor Martinez on a long drive to left-center.

Detroit added two runs in the eighth. Tim Wakefield walked Jeff Frazier and allowed a single to Gerald Laird before both runners moved up on a sacrifice by Danny Worth. Frazier scored and Laird took third on a wild pitch, then scored on a groundout.

Notes: LF Johnny Damon was a late scratch for Detroit with upper back spasms. ... Frazier, called up Friday after hitting 23 homers for Toledo (IL) this season, went 0 for 3 with two strikeouts as the DH. ... Boston OF Jacoby Ellsbury, on the DL since May 28 with fractured ribs, is scheduled for a rehab appearance Saturday with Pawtucket (IL). ... Lester allowed four runs and 11 hits in six innings with seven strikeouts and two walks. He has at least six strikeouts in each of his last nine games.