Yovani Gallardo (4-5) overcame a shaky first inning to stop a four-game skid, the worst of his career. Yuniesky Betancourt added three hits and an RBI for the Brewers, who avoided setting a dubious record for the worst month in franchise history.
Milwaukee finished May with a .214 winning percentage (6-22) to tie the Seattle Pilots, who went 6-22 in August 1969 during their lone season before becoming the Milwaukee Brewers in 1970.
It was the third time in club history that a team won just six games in a month.
Gallardo tossed 5 2-3 innings while allowing five runs on six hits with six strikeouts and three walks. Francisco Rodriguez pitched a scoreless ninth for his second save.
Domonic Brown continued his power surge with a pair of homers and four RBIs for the Phillies. Brown has six home runs in his last five games and finished May with 12 homers. Jimmy Rollins also went deep for Philadelphia, which has lost four of six.
Hamels (1-9) combined some bad luck and bad pitching into another defeat. The left-hander, who signed a $144 million, six-year contract last season, left to a mixture of boos and cheers after giving up seven runs (six earned) on a career-worst 12 hits with three strikeouts and no walks in five-plus innings.
The Brewers scored four runs on five hits in a third inning that was indicative of Hamels' strange season.
Norichika Aoki led off with a chopper over the mound that just eluded Hamels. Jean Segura reached on an error and Ryan Braun's weakly hit pop fly fell in short right between three charging Phillies to load the bases.
Aramis Ramirez drove in Aoki with a broken-bat single that found a hole on the right side of the infield. Carlos Gomez followed with a sacrifice fly that was the first solidly hit ball of the inning, and the Brewers got another run on Lucroy's solid single to right. Milwaukee went up 6-3 on Betancourt's infield single that deflected off Hamels' glove.
There was nothing fluky, though, about Lucroy's long homer to left that opened the fifth and put Milwaukee up 7-4.
Brown hit the second of his two homers, a long shot to right, leading off the sixth to pull Philadelphia to 7-5. But the Phillies didn't get a hit off four Brewers relievers in 3 1-3 scoreless innings.
Philadelphia got off to a good start, taking a 3-0 lead in the first inning - highlighted by Brown's two-run homer to right - to give Hamels his first lead in 62 innings since April 7.
Lucroy launched his second homer into the Phillies bullpen in center off right-hander Mike Adams with two outs in the eighth.