The 28-year-old had been negotiating with the club since spring training and talks intensified as the non-waiver trading deadline approached. Hamels was offered a six-year, $126 million contract over the All-Star break.
The pressure of pitching for his next deal didn't appear to weigh on Hamels this season. He's 11-4 with a 3.23 ERA and 131 strikeouts. He has an 85-58 record with a 3.38 ERA.
The Phillies were negotiating against the clock and with Hamels signed, might have to listen to offers on their other marketable assets, including 35-year-old starting pitcher Roy Halladay and 33-year-old starter Cliff Lee.
The Phillies have $89 million in total salary committed to the three starting pitchers and first baseman Ryan Howard next season.
Hamels' deal would be the second-richest for a pitcher in baseball, behind only the six-year, $161.5 million deal the Yankees gave CC Sabathia. Hamels surpasses Johan Santana, who signed a $137.5 million, six-year deal with the Mets.