Lee (13-7) allowed two runs and three hits, striking out seven. The All-Star lefty has won four straight starts. Lee's 18-inning scoreless streak ended when Paul Goldschmidt hit a two-run homer for the NL West leaders.
Jimmy Rollins hit a leadoff homer for the major-league leading Phillies, who've won 11 of 14 this month.
Diamondbacks starter Joe Saunders (8-10) pitched well before unraveling in the seventh. He gave up five runs and five hits in six-plus innings.
Hunter Pence walked to start Philadelphia's seventh and advanced to third on John Mayberry Jr.'s single to right. Valdez followed with a double off the wall in straightaway center to put the Phillies up 4-2. Pinch-hitter Ben Francisco's sacrifice fly extended the lead to 5-2.
Rollins hit a sac fly and Shane Victorino doubled in a run during a four-run eighth for Philadelphia.
Rollins hit Saunders' first pitch of the game out to deep left-center for his 37th career leadoff homer and second this season.
Goldschmidt connected in the second to give the Diamondbacks a 2-1 lead. He has three homers in 14 games since making his big-league debut on Aug. 1. Goldschmidt's first came off two-time Cy Young Award winner Tim Lincecum and his second was a tying two-run shot in the ninth against Houston last Thursday.
The Phillies answered in the bottom half. Pence led off with a double and Mayberry followed with an RBI single to center. Pence inexplicably slid into third and still had to time to get up and score without a throw from center fielder Chris Young. He got high-fives from chuckling teammates in the dugout.
Lee nearly put the Phillies ahead when he hit a two-out grounder up the middle with a runner on third. But second baseman Ryan Roberts made a backhanded grab and his strong throw to first barely got Lee, who reacted angrily to the call. Manager Charlie Manuel came out to argue briefly, and received a standing ovation for doing so.
A crowd of 45,894 was the 199th straight sellout at Citizens Bank Park, including postseason play, and the largest in the regular season in the ballpark's eight-year history.
Notes: Phillies C Carlos Ruiz wasn't in the starting lineup because of a bruise in the groin area. ... The Phillies are 17-3 on Wednesdays. They are 13-3 with Pence in the lineup. ... The Diamondbacks are one of five teams with two seven-game winning streaks this year. ... Rookie Vance Worley (8-1) pitches for the Phillies against Ian Kennedy (15-3) when the teams wrap up their series Thursday night. Worley has never faced Arizona. He's coming off his worst start of the season in which he allowed six runs in four innings in a 9-8 win at Los Angeles. Kennedy tossed his only career shutout against the Phillies, a three-hitter earlier this season.