The Phillies finished with 16 hits and a season-high run total after Houston starter Chris Sampson allowed only five hits through the first five innings.
"It's one of those things where you have guys who are power hitters and guys who also have good averages," said Hamels, who gave up six runs in four innings, his shortest outing of the season. "They're going to put the ball in play, get a lot of hits. That's what we were able to do and that turned it around for us."
Hamels had pitched at least seven innings in nine of his 10 starts this season.
"It was probably one of the worst games I've pitched all season," Hamels said. "I'll try to make it be the only worst game I'll pitch."
The Astros led 6-4 when he left, but Philadelphia scored 11 runs off the Houston bullpen to pull away.
Reliever Fernando Nieve (0-1), called up from the minors on May 16, gave up four hits and two runs without recording an out in the sixth and Utley hit a two-run homer off Dave Borkowski to cap a six-run seventh.
Nieve was optioned to Triple-A Round Rock after the game and the Astros recalled right-hander Jack Cassel.
"He just had bad location," said Houston manager Cecil Cooper, "and when you have bad location against these guys, you are going to pay."
Carlos Lee hit a three-run homer for Houston, moments after accidentally hitting plate umpire Jerry Crawford in the head with his bat. The game was delayed 12 minutes as Astros trainers treated a bloody gash on the left side of Crawford's head.
Crawford was taken to hospital for tests and did not need stitches. He was back at the ballpark later and said he had a mild headache.
First-base umpire Rob Drake took over behind the plate after Crawford was hurt. Two pitches later, Lee homered to left, the first runs allowed by Hamels in 19 innings.
Hamels said the delay threw off his concentration.
"With a good-hitting player up, a guy who's very dangerous, to go in there with two strikes, it's like sort of a reliever-type situation," Hamels said. "I threw two balls and he hit one out. That's the type of player he is. He's a scary hitter."
The Astros scored two runs in the third before Hamels drove in a run with a single in the fourth, his first RBI of the season.
Ty Wigginton, 7-for-10 in the first three games of the series, doubled off the left-field wall in the fourth and went to third on Sampson's single. Wigginton scored when Michael Bourn grounded into a fielder's choice.
Hamels hadn't allowed more than five runs in a start this season and Phillies manager Charlie Manuel brought in reliever Rudy Seanez (3-3) for the fifth.
"It was just a little bit of everything today," he said. "I just didn't have my good stuff. The ballclub that Houston has, when you're not able to really locate, you can find yourself in a lot of trouble."
When Nieve relieved Sampson, Burrell led off the sixth with a homer to left, his third solo home run in four games. After Carlos Ruiz's RBI single tied the game at 6, Houston manager Cecil Cooper replaced Nieve with Wesley Wright. Victorino added a two-run double before Wright retired the side.
Eight of Philadelphia's 16 hits went for extra bases.
"We have a lot of confidence in our ourselves and our ability to put up some runs," Utley said. "You've just got to stay positive and try to stay within yourself and see what happens."
Burrell doubled and Jenkins singled to right off Borkowski in the seventh. Lance Berkman dove to his right, trying to stop Jenkins' hit, and appeared to hurt his right hand. Trainer Rex Jones ran out to check on it, but Berkman stayed in the game.
Greg Dobbs had a pinch-hit, two-run triple and Victorino brought him home with a single to make it 13-6. Utley then homered to right, his 15th.
"I was terrible today and for me, there is no excuse," Borkowski said. "I thought I was throwing strikes, but when I was missing, everything was up and they just killed me."
The Astros mustered only two hits in the last four innings. The Phillies' bullpen came into the game with the lowest ERA in the majors at 2.85.
The Astros stole four bases, boosting their major league-leading total to 60. ... Berkman has stolen 10 bases this season, already a career high. ... The Phillies are 17-2 when leading after seven innings. ... The Phillies took the season series from the Astros 4-3.