With the bases loaded against Kevin Correia (2-2) and two outs, Grandal punched a single into right field that allowed Yangervis Solarte to score and end the game.
Alexi Amarista and Rene Rivera each drove in a run for the Padres, who have won three straight. Tim Stauffer (5-2) pitched a scoreless inning of relief for the win.
Hanley Ramirez went 3-for-4 with a solo home run and two RBI for the Dodgers, who had won five of six coming in.
Neither starting pitcher factored into the decision as Dan Haren tossed six innings for Los Angeles and allowed two runs -- one earned -- on five hits with a walk and three strikeouts. Andrew Cashner allowed a run on six hits with eight strikeouts in six innings for San Diego.
The Padres got on the board in the second as Grandal walked and moved to third on Jedd Gyorko's bunt coupled with a bad throw from Dee Gordon. Rivera followed with a sacrifice fly for a 1-0 lead.
Los Angeles tied the game in the third on a run-scoring double from Ramirez that plated Justin Turner.
San Diego went back on top in the fourth as three straight singles from Rivera, Rymer Liriano and Amarista made it a 2-1 game.
Ramirez, though, tied the game in the eighth with a towering blast to left for his 13th home run of the season.
Los Angeles left the bases loaded in the top of the ninth, while the Padres stranded men on first and second in the home half to send the game to extra innings.
Both teams left 11 men on base as the Dodgers were 1-for-9 with runners in scoring position while the Padres went 2-for-10 ... Los Angeles still leads the season series with San Diego, 9-5.