San Francisco Giants starting pitcher Yusmeiro Petit throws to Colorado Rockies in the first inning of their game on Thursday in San Francisco.

AFP/New York

Yusmeiro Petit pitched six dominant innings, striking out nine batters en route to making history in the San Francisco Giants’ 4-1 Major League Baseball victory over the Colorado Rockies on Thursday.

Petit retired the first eight batters he faced to break Mark Buehrle’s MLB record with 46 consecutive outs.

Petit improved to 2-2 as a starter after allowing just one run on four hits over six innings of work. Petit also struck out nine before leaving after making just 81 pitches.

Petit has split his playing time this season between starting and coming out of the bullpen. He tied the National League record for consecutive batters retired of 41 with a 1-2-3 first inning.

Giants batter Pablo Sandoval led off the second inning with a single, and after Hunter Pence popped up in the infield, Gregor Blanco crushed a Jordan Lyles’ pitch over the fence to make it 2-0.

Petit struck out Jackson Williams to open the third inning and match Buehrle’s mark. Another strikeout of Rockies batter Charlie Culberson gave him the record.

Lyles broke up the historic streak one batter later when he smacked a double to the wall in the left field. Charlie Blackmon then blooped a single to left, and Lyles made an impressive slide to get under Blanco’s throw home to give the Rockies their lone run.

Giants batter Pence added a sacrifice fly in the sixth, and Andrew Susac drove in Sandoval in the eighth with a single to make it 4-1.

San Francisco relief pitcher Santiago Casilla walked the leadoff batter in the ninth inning but retired the next three he faced to earn his 12th save of the season.

Elsewhere, Alex Avila lined the first pitch he saw in the ninth inning to score pinch runner Bryan Holaday from second base and give the Detroit Tigers a 3-2 victory over the New York Yankees.

Victor Martinez had lined a double over the shift into the right field corner leading off the ninth against reliever Shawn Kelley and was replaced by Holaday.

Rookie lefty Kyle Lobstein, making his first major league start and his second appearance, allowed four hits in his six innings of work for Detroit (72-60) who pulled within a game and a half of first-place Kansas City.

Right-hander Hiroki Kuroda went the first seven innings for New York, allowing two runs on four hits with four strikeouts.

J.J. Hardy blooped an RBI single to short right field in the seventh inning that gave the Baltimore Orioles a 5-4 victory over the Tampa Bay Rays.

The Orioles (76-56) stretched their American League East lead over the Yankees (69-63) to seven games with 30 to play.

Baltimore started the winning rally when left fielder Nelson Cruz lined a double to left field before the Rays (65-69) intentionally walked third baseman Chris Davis to get to Hardy.

Second baseman Brian Dozier and left fielder Jordan Schafer each drove in two runs in a six-run 10th inning as the Minnesota Twins toppled the Kansas City Royals with a 11-5 verdict.

Left-hander Tommy Milone, who is winless in four Minnesota starts since being acquired in a July 31 trade with Oakland, left after 5-1/3 innings, allowing four runs on nine hits and two walks.

He left with a 5-4 lead, but the bullpen failed to hold it.