SAN FRANCISCO -- All-Star selection Madison Bumgarner took a perfect game into the fifth inning before settling for a three-hitter over seven, helping the San Francisco Giants snap a four-game losing streak Saturday with a 4-2 victory over the Los Angeles Dodgers in a game that featured a rare batting-out-of-order infraction.
Andre Ethier's two-out, two-strike bloop single to left field in the fifth produced the Dodgers' first baserunner against Bumgarner (9-5), who helped himself by driving in half the San Francisco runs with a bases-loaded walk in the second and a sacrifice fly in the fourth.
Both RBIs came against Dodgers starter Stephen Fife (3-3), who was charged with only two earned runs among the four runs he allowed in 4 ? innings. Gregor Blanco had three of San Francisco's seven hits off Fife -- a pair of doubles sandwiching an RBI single in the Giants' three-run second inning.
Bumgarner struck out nine and didn't walk a batter in his seven innings, permitting catcher Tim Federowicz's two-run homer after Ethier's single in the fifth inning but just one hit -- a Hanley Ramirez triple that extended his hitting streak to 17 games -- other than that.
One-third of Bumgarner's strikeouts came against Dodgers rookie sensation Yasiel Puig, who entered the game with a .420 batting average but never put the ball in play against the Giants ace.
Facing a hot Dodgers team that had averaged 6.0 runs per game in their previous 10 games and had recorded 10 or more hits in five straight contests, Bumgarner allowed just two runs, the sixth consecutive start in which he's permitted three or fewer.
Relievers Sandy Rosario and Javier Lopez combined on a scoreless eighth inning before closer Sergio Romo slammed the door on the Dodgers' four-game winning streak over the Giants, recording his 20th save after opening the ninth with Puig's fourth strikeout of the game.
The Giants out-hit LA 7-4.
The Dodgers had won five of their previous six games and 11 of 13. LA relievers J.P. Howell, Ronald Belisario and Paco Rodriguez held the Giants hitless over the final 3 ? innings, striking out eight.
Bumgarner had retired the first 14 Dodgers in order two outs into the fifth inning before nearly striking out Ethier with a 2-2 fastball that was called a bit outside. After Ethier fouled off Bumgarner's next pitch, he blooped a single in front of a sliding Andres Torres in left field for L.A.'s first hit.
Two pitches later, the shutout was gone as well when Tim Federowicz belted his third home run of the season, a no-doubt, two-run shot to left field that trimmed San Francisco's lead to 4-2.
The Giants gave Bumgarner a four-run cushion through four innings, getting help from a shaky Dodgers defense along the way.
LA second baseman Nick Punto's wild throw to second base on Brandon Crawford's ground ball loaded the bases for the Giants in the second inning rather recording the second out.
Fife then walked Bumgarner on five pitches to force in the first run of the game. Gregor Blanco's infield hit and Marco Scutaro's sacrifice fly made it a three-run inning, with two of the runs unearned.
Andres Torres hit a ball through shortstop Hanley Ramirez's legs to set up a Giants run in the fourth. Bumgarner helped himself at the plate once again, getting a second RBI with a sacrifice fly to deep right field to make it 4-0.
The game got off to an unusual start when Giants catcher Buster Posey, batting third, grounded an apparent run-scoring double down the right-field line in the bottom of the first inning.
After the hit, Dodgers manager Don Mattingly approached home-plate umpire Tony Randazzo, lineup card in hand, and insisted the Giants were batting out of order. The umpires agreed, sending Blanco back to third base, calling Pablo Sandoval (the No. 3 hitter on the lineup card) out and bringing Posey back to the plate.
Posey flied out to right field in his second crack at Fife, ending the inning.
NOTES: Bumgarner, Scutaro and Posey were selected as National League All-Stars from the Giants, the defending World Series champs. Bumgarner and Scutaro were added by NL manager Bruce Bochy of the Giants; Posey earned a reserve spot via player balloting. ... LHP Clayton Kershaw, LA's scheduled starter in Sunday's series finale, was the lone Dodger selected for the July 16 midsummer classic at the home of the New York Mets, Citi Field. ... The Dodgers, one of the hottest teams in baseball in the past half-month, were one of five NL teams to get only one representative in the game. San Diego, Chicago, Atlanta and Miami were the others. ... Dodgers RF Yasiel Puig and 1B Adrian Gonzalez and Giants RF Hunter Pence were among the five NL players selected for the last-man-in fan balloting that began Saturday. ... Dodgers CF Matt Kemp, who suffered irritation in the AC joint in his left shoulder in Friday's game, sat out Saturday after getting a cortisone shot. He hasn't been ruled out of Sunday's game but is unlikely to play. ... Sandoval was officially credited with an out for the at-bat lost in the batting-out-of-order incident. ... The Giants had led in just two of the previous 36 innings before their three-run second against Fife.