The Astros scored the go-ahead run in the sixth when No. 9 batter Zack Short capped an eight-pitch at-bat by drawing a two-out bases-loaded walk off reliever Will Klein (1-1) for a 2-1 lead.
Walker and Diaz opened the eighth with homers off Dodgers closer Tanner Scott for a 4-1 lead, and Altuve added a solo shot in the ninth off Anthony Banda, as the Astros improved to a major league-best 24-8 since June 1.
Gusto (6-3) wasn’t dominant, allowing one run and four hits and striking out one, but he held the top four Dodgers batters — Shohei Ohtani, Mookie Betts, Freddie Freeman and Andy Pages — to two singles in 12 at-bats.
Bennett Sousa, Bryan King and Bryan Abreu each threw scoreless innings of relief for Houston.
The Dodgers took a 1-0 lead in the second, an inning that began with Michael Conforto’s walk and Hyeseong Kim’s single. Conforto took third on Miguel Rojas’ double play grounder and scored on Dalton Rushing’s RBI double.
Houston tied the score 1-1 in the third when Short singled, took third on Isaac Paredes’ double and scored on Altuve’s sacrifice fly, a ball that Dodgers right fielder Esteury Ruiz caught while leaping into the screen in foul territory.
Dodgers right-hander Emmet Sheehan, recalled from triple-A to make his second big-league start in his return from Tommy John surgery, gave up one run and five hits in five innings, striking out four and walking one.
The Dodgers threatened off reliever King in the eighth when Rushing singled and took second on Betts’ two-out single, but Astros centre fielder Taylor Trammell, who entered for defensive purposes in the sixth, raced in to make a sliding catch of Freeman’s 104-m.p.h. liner to preserve a 4-1 lead.
Walker, who entered with a major league-best 1.203 career OPS in Dodger Stadium, is batting .349 (53-for-152) with 21 homers and 38 RBIs in 45 games in Chavez Ravine.
Dodgers right-hander Yoshinobu Yamamoto (8-6, 2.51 ERA) will face Brewers right-hander Freddy Peralta (9-4, 2.91 ERA) Monday in Milwaukee.
Astros left-hander Colton Gordon (3-1, 4.37 ERA) will face Guardians right-hander Tanner Bibee (4-9, 4.20 ERA) Monday in Houston.