Alvarez lined a bases-loaded single in the bottom of the 10th inning to give the Pittsburgh Pirates a 5-4 victory Friday night.
Left-hander J.P. Howell relieved and manager Don Mattingly moved an outfielder into the infield but the left-handed hitting Alvarez singled into right field for the game-winning hit.
"You don't care where the defense is," Alvarez said. "My entire focus of the at-bat is on the pitcher and what he's trying to do. That's all you can control."
The Pirates won for the 13th time in their last 16 home games and improved to 37-18 at PNC Park this season. They are 12-2 against NL West teams.
This marked the first time the major league's win leader (Pittsburgh's Gerrit Cole) faced the major league's strikeout leader (Kershaw) this late in a season since the Chicago White Sox's Wilbur Wood squared off against the California Angels' Nolan Ryan on Aug. 11, 1973, according to the Elias Sports Bureau.
However, the pitching duel did not materialize.
Kershaw, who had won his previous four starts, gave up four runs and nine hits in six innings with two walks and five strikeouts.
"It was a tough one," Kershaw said. "I struggled all the way through pretty much and give the Pirates credit. They did a good job battling me the whole night and I just didn't really have good stuff."
Kershaw raised his season strikeout total to 197, leaving him three shy of a sixth straight season with at least 200.
Cole allowed three runs and four hits in six innings while striking out five and walking three. His record remained 14-5, though, and he has only one win in four starts since the All-Star break.
Cole pitched at least six innings for the 18th time in 22 starts this season -- the other four have been against Cincinnati. He has allowed three runs or fewer in all but one start.
"I was really sporadic at times," Cole said. "In the heat of the moment, though, you're just trying to prevent runs from going up on the board and do the best you can. Fortunately, we caught (Kershaw) on a kind of an off night, too. It was just kind of weird game, not what everyone expected."
Antonio Bastardo (4-1) pitched a scoreless 10th for his second win in as many games.
The Dodgers tied it 4-4 in the seventh inning when Rollins hit a two-out RBI double.
Kershaw had not allowed a run since July 5, against the New York Mets. The major league record is 59 innings, set by Orel Hershiser in 1988 with the Dodgers.
Polanco homered to lead off the bottom of the first for the second straight game, having connected off the Cubs' Dan Haren on Wednesday night. Polanco has six home runs this season.
"Polanco made it happen in a hurry," Pirates manager Clint Hurdle said. "We knew Kershaw was going to attack and Gregory got to it with the barrel."
The Pirates went ahead 4-3 with a two-run fifth inning. McCutchen hit an RBI double and scored on Ramirez's single.
Rollins put the Dodgers ahead 3-2 in the fifth with a one-out RBI single.
The Pirates pulled into a 2-2 tie in the fourth when Chris Stewart drew a bases-loaded walk from Kershaw with two outs after the Dodgers had gone ahead on Kendrick's single in the third.
Dodgers: 3B Justin Turner (right thigh infection) began hitting off a tee and throwing Friday at the Camelback Ranch training complex in Glendale, Arizona, but he won't be ready to come off the DL next Tuesday when first eligible, as hoped. He likely will be activated later in the week.
Pirates: RHP Deolis Guerra (right knee inflammation) was placed on the 15-day DL, retroactive to July 31, after Major League Baseball rescinded a waiver claim by Cleveland because of the injury.
Dodgers: RHP Mat Latos, who starts Saturday, is 5-1 with a 3.13 ERA against the Pirates in 12 career starts.
Pirates: LHP Francisco Liriano has won all three career starts against the Dodgers with a 1.37 ERA.
Max Scherzer brings an impressive highlight reel into free agency
Check out some of Max Scherzer's highlights with the Nationals and Dodgers as the righty gets set to join the Mets.
MLB free-agency tracker: Latest moves, grades and analysis
Need to keep tabs on all the major signings? Want to know how our experts grade the big deals? We've got you covered.
Sources: New York Mets, Max Scherzer agree to three-year, $130 million contract
Three-time Cy Young Award winner Max Scherzer and the Mets have agreed to a three-year, $130 million contract, sources familiar with the situation told ESPN's Jeff Passan.
Is an MLB lockout coming? Will free agency freeze? Jeff Passan answers 20 burning questions
Baseball is facing its biggest labor reckoning in a quarter-century. Where do things stand -- and is it time for fans to panic?
MLB free-agency grades: Toronto Blue Jays look to Kevin Gausman to complete rotation
The Giants' pitching factory unlocked Kevin Gausman's true potential. Will he keep it up with the Blue Jays?
What happens to Marcus Semien's fantasy value in Texas?
Tristan H. Cockcroft explains the fantasy implications of Marcus Semien signing as a free agent with the Texas Rangers.