PHILADELPHIA -- Cole Hamels knew the moment he walked off the mound to a standing ovation after allowing five runs in his last start that he was staying with the Philadelphia Phillies.

"Words can't really describe the emotions that you get, and the way the fans were standing and cheering, that was ultimately the deciding point to be here," Hamels said.

He had $144 million other reasons to stay, too.

Hamels on Wednesday signed a six-year contract worth an average of $24 million per season that prevents the 2008 World Series MVP from becoming a free agent in November. The deal includes a club vesting option for 2019 and a limited no-trade provision.

The contract is the largest signed by a Philadelphia athlete and second-highest for a pitcher behind the $161 million, seven-year deal the New York Yankees gave CC Sabathia in December 2008.

"It was long and laborious," general manager Ruben Amaro Jr. said about negotiations, which started last May. "We finally got to the finish line. (Six years) is unprecedented for the Phillies, but we did it with the right person."

The 28-year-old Hamels becomes the third Phillies starter making $20 million per season, joining Roy Halladay and Cliff Lee. A three-time All-Star, Hamels passed up an opportunity to possibly get more money on the open market to stay with the team that drafted him in 2002.

"I wanted to give the Phillies every opportunity," Hamels said. "It's very hard to leave a place that you've had so many great memories. You don't want to miss it and not be a part of it. I know the organization has always done a good job of going out to win. We have great players here. You don't want to have to leave that or stray away and see them win and you're not part of it.

"I understand that free agency is great, those opportunities of the unknowing. But this is the place that I call home and want to call home for a really long time. I grew up watching Tony Gwynn play and he made San Diego his home for his entire career. That's ultimately what I want to make here in Philadelphia."

Hamels is 11-4 with a 3.23 ERA this season. The lanky lefty is 85-58 with a 3.38 ERA in seven years in Philadelphia. Hamels has never won more than 15 games in a season, and his 2.79 ERA in 2011 was the only time he was under 3.06.