Houston starter J.A. Happ (3-6) walked Jamey Carroll with two outs in the third inning before a single by James Loney. Matt Kemp reached on an error by second baseman Bill Hall when couldn't handle a grounder by Kemp to set up the slam to left-center field by Sands.
The home run by Gibbons to right field in the second inning put Los Angeles up 1-0.
Dodgers starter Chad Billingsley (3-4) yielded five hits and four runs with nine strikeouts to get his first win this month.
Carlos Lee drove in two runs in Houston's three-run third inning.
Rubby De La Rosa, who was called up from Double-A Chattanooga on Tuesday, pitched a 1-2-3 eighth inning for the Dodgers in his major league debut. Javy Guerra pitched a perfect ninth for his first major league save.
Billingsley pitched a perfect fourth and fifth before Pence doubled to start Houston's sixth inning. He walked Lee and Brett Wallace to load the bases. Chris Johnson's sacrifice fly to center field scored Pence and cut the lead to 5-4. Billingsley was able to limit the damage by retiring the next two Astros to end the inning.
Lee drove in two with a single to center to get the Astros within 5-3 before Wallace struck out to end the inning.
Happ (3-6) allowed three hits and five runs — one earned — in five innings for the loss.
The grand slam by Sands was the first by the Dodgers this season and the second home run of his career after he was called up from Triple-A Albuquerque on April 18.
Happ retired the next seven batters after the slam.
Loney extended his hitting streak to a season-long 10 games with his single in the third inning.
NOTES: Dodgers OF Andre Ethier was out of the lineup for the second straight game after being taken out of Sunday's game after running into the outfield wall. Manager Don Mattingly said he's OK, but there were a couple of reasons why he decided to give him another day off. "With the lefty tonight, it would probably be an easy chance to give him another day," Mattingly said. "I need him to be able to go 100 percent. Last year he got banged up and he was hobbling around the whole time out there the whole second half of the year. I just don't want to see that." ... Houston OF/INF Jason Bourgeois, on the disabled list with an oblique strain, felt good on Tuesday, a day after taking swings for the first time since his injury. He hopes to take batting practice by the end of the week.