SAN FRANCISCO (AP) Jake Peavy pitched five innings for his fifth consecutive win, rookie Kelby Tomlinson hit an inside-the-park home run and the San Francisco Giants beat the Colorado Rockies 3-2 on Saturday.

Brandon Crawford and Marlon Byrd also homered for the Giants, who had lost two straight and three of four before powering up to beat the Rockies for just the eighth time in 18 meetings this year.

It was the 12th time this season San Francisco hit three home runs or more in a game.

More from FoxSports

Peavy (8-6) allowed one run and four hits to improve to 5-0 over his last eight starts. He struck out two, walked one and retired 12 of his final 14 batters.

Ben Paulsen homered for the Rockies, who have lost four of five.

Tomlinson, whose only other home run came on Aug. 27, hit the eighth inside-the-park shot in AT&T Park history and the first since Angel Pagan did it on May 25, 2013. He benefited when Colorado center fielder Corey Dickerson and right fielder Carlos Gonzalez both paused to stare at each other briefly after chasing the ball down near the wall.

That gave the San Francisco rookie just enough time to slide home and easily beat the relay throw from second baseman DJ LeMahieu.

One out later, Byrd hit his 23rd home run of the season and fourth with San Francisco to make it 2-0.

Crawford's 21st of the year put the Giants up 3-0 in the fourth.

All three of San Francisco's runs came off Rockies starter Chris Rusin (6-10). The lefty gave up five hits in six innings with four strikeouts and two walks.

Tomlinson also turned in a sparkling defensive play when he made an over-the-shoulder catch on LeMahieu's high popup to shallow right to end the fourth.

Paulsen homered off Peavy leading off the fifth.

Dickerson doubled off Josh Osich and scored in the sixth to pull the Rockies to 3-2.

Five relievers combined to pitch the final four innings for San Francisco. Santiago Casilla retired two batters for his 38th save.

Nolan Arenado doubled for Colorado, extending his major league record for extra-base hits by a third baseman to 89.

TRAINER'S ROOM

Rockies: C Tom Murphy exited with a strained left shoulder after getting picked off second base to end the fifth. He was replaced by Dustin Garneau.

UP NEXT

Rockies: RHP Christian Bergman (3-1) pitches the season finale. He is winless in 11 appearances on the road despite a 2.37 ERA.

Giants: RHP Matt Cain (2-4) will make his first start since Aug. 25 in the last game of the year for the defending World Series champs. Cain has won once in his four starts at AT&T Park this season.