Lee's fifth-inning sacrifice fly snapped a 2-2 tie.
A run scored on Alex Romero's third-inning error, and Kaz Matsui drove in a run for the Astros, who have won five of their last six games.
Winner Brian Moehler (8-9) gave up two runs and six hits in 5 2/3 innings.
LaTroy Hawkins earned his 11th save with a 1-2-3 ninth.
Arizona scored on Gerardo Parra's first-inning single and a second-inning groundout by Mark Reynolds.
Augie Ojeda had two of the eight hits for the Diamondbacks, who have lost seven in a row.
Losing pitcher Max Scherzer (7-8) gave up four runs and seven hits in five innings with two walks and seven strikeouts.