DETROIT -- The Detroit Tigers capped a feel-good day with some sadness.
The Tigers found out at least four of them were All-Stars before the game, but no one was in the mood to celebrate the win or the selections because pitching coach Rick Knapp was fired soon after the final out.
"Mixed emotions, obviously," manager Jim Leyland said. "We just felt like it wasn't working."
Rick Porcello (7-6) gave up three runs and five hits over seven innings in a much-needed performance for Detroit's suddenly shaky rotation. He became the fifth pitcher since 1919 to have three wild pitches and hit three batters in a game.
"A little bit wild, but his stuff was much better," Leyland said.
Jeremy Affeldt (1-2) took the loss after third baseman Miguel Tejada's throwing error extended the seventh inning. Ordonez took advantage with a single off Santiago Casilla that put Detroit ahead 4-3.
Brandon Inge gave the Tigers a three-run lead in the eighth with a two-run, two-out triple.
Detroit had lost two straight and four of five, falling out of first place in the AL Central.
"It was a big win because good teams don't get swept," said Brennan Boesch, who hit a game-tying homer in the fourth.
The NL-West leading Giants had won nine of 11.
"You can see why they're the world champions," Leyland said.
San Francisco appeared to have a shot to retake the lead in the eighth inning when Aaron Rowand drove a ball to left-center, but Raburn sprinted and fully extended to snatch the ball.
"From my angle I didn't think Raburn had a chance, but he made a great diving catch," Giants manager Bruce Bochy said. "If he doesn't make that, we take the lead and then we have a different bullpen strategy."
Porcello gave up a double on his first pitch, then allowed only one more hit before Brandon Crawford's RBI groundout in the fourth inning. Detroit tied it in the home half with Boesch's solo homer off the foul pole in right.
The Giants went ahead in the fifth on Porcello's wild pitch and Cody Ross' RBI single gave them a 3-1 lead.
Detroit cut into the deficit when Miguel Cabrera hit a single to left and Ross mishandled it, allowing Boesch to score on the error.
Tejada had a chance to keep the Tigers scoreless in the seventh, but his throw across the diamond in the dirt wasn't scooped up by first baseman Pablo Sandoval on what should've been the third out of the inning.
"The error really hurt us because we had a chance to get out of that," Bochy said. "This was a tough one to lose. It would have been a big boost to sweep this team.
San Francisco starter Ryan Vogelsong, a first-time All-Star, allowed three runs -- two earned -- on four hits and four walks in 6 2/3 innings.
Bochy picked three of his pitchers -- Matt Cain, Tim Lincecum and Vogelsong -- to be All-Stars and another one, Brian Wilson, was selected by the players. ... Detroit's Alex Avila was voted an All-Star by the fans, Cabrera and Justin Verlander were picked by the players, Valverde was a manager's selection, and Victor Martinez has a chance to be voted in as the Tigers' fifth player. ... San Francisco matched a season high with three errors. ... Porcello joined Victor Zambrano (2003), Joe Niekro (1985), Pete Broberg (1971), Rip Collins (1923) as the pitchers since 1919 to have to hit at least three batters and have at least three wild pitches in a game. ... Sandoval extended his career high hitting streak to 14 games. ... The Tigers recalled LHP Adam Wilk from Triple-A Toledo and optioned RHP Brayan Villarreal to the Mud Hens.