He retired the first six batters in order before allowing a leadoff single to Hunter Renfroe in the third, but induced three quick outs to end the threat and didn't allow another batter past first base for the rest of his start.
The Padres (71-91) lost for the sixth time in seven games as they concluded their seventh straight losing season with a modest improvement of three more wins than last season.
Giants fans responded with a standing ovation, one upon which the Padres joined.
Conte: Man City match not simple for exhausted Chelsea
His first start of the season went amazingly well and he was Chelsea's best player on the pitch. City created a chance and were very good to take the chances to score.
After having announced his retirement earlier in the week, Cain shut out the Padres on two hits over five innings in his first outing since August 29. Stratton suffered through his worst appearance of the season against San Diego on April 29, when he was lit up for five runs on four hits and a walk in one-third of an inning of relief. The 24-year-old right-hander threw a season-high 108 pitches. Giants' skipper Bruce Bochy approached the mound, incurring a stream of boos from the crowd, but ultimately chose to leave the rest of the inning to his starter.
The second RBI of the day was Pence's 67th of the season, tying him with Buster Posey for second on the team behind Brandon Crawford's 76.
Giants clinch No. 1 pick with a loss or a Tigers win.
The Padres out-hit the Giants 8-6. Padres 1B Wil Myers became the first San Diego player to hit 30 home runs in a season since 3B Chase Headley in 2012.
He has a career record of 104-118 with a 3.69 ERA, and on June 13, 2012, Cain pitched a ideal game against the Houston Astros.