"Ensuring that Matt remained a Giant beyond this season was a top priority for the organization. Matt is an integral part of the team whose performance on the mound will be one of the keys to our success for years to come," Sabean said.

Among pitchers, only the Yankees' CC Sabathia and the Mets' Johan Santana, both left-handers, agreed to larger contracts. Sabathia got a $161 million deal from 2009-2015 that had an additional year and $30 million in guaranteed money added last fall. Santana agreed to a $137.5 million contract from 2008-13.

The previous record contract for a right-handed pitcher was Kevin Brown's $105 million, seven-year deal with the Dodgers after the 1998 season.

"It's an honor to be in this situation. We're trying to take that all in and embrace it," Cain said. "It's great to be mentioned with any of the names in that category. It's nice to be spoken in the same sentence with Santana and Sabathia."

The 27-year-old Cain went 12-11 last season with a 2.88 ERA, reaching 200 innings for the fifth straight season. He also didn't allow an earned run during the entire 2010 postseason, when the Giants pulled off an improbable World Series championship.

"This kid literally has gotten better each year and has proven that under very difficult circumstances," Sabean said.

Cain, represented by CAA Sports, never named his price tag or the number of years he sought, other than to say during spring training he wanted "fair value." Several other top pitchers around the majors have signed similar contracts for five years -- Phillies ace Cliff Lee ($120 million), and the Angels' duo of Jered Weaver ($85 million) and C.J. Wilson ($77.5 million).

"Both sides always felt they were pushing in the right direction," Cain said.

According to the AP, Cain can earn an additional $500,000 for winning the Cy Young award, $250,000 for second place, $100,000 for third, $75,000 for fourth and $50,000 for fifth. He would receive $1 million for a second or subsequent Cy Young. He also would get $250,000 for MVP, $150,000 if second, $100,000 for third, $75,000 for fourth and $50,000 for fifth.

Cain gets $200,000 if named World Series MVP and $150,000 if chosen NL Championship Series MVP, plus $100,000 for being selected an All-Star. He also could make $50,000 for a Gold Glove or Silver Slugger award.

The Giants said their talks with Cain's representatives were professional and constant in hopes of coming to an agreement before the Giants open the season Friday at Arizona. Sabean said the framework was in place, but finalizing details on the years and dollar figures happened over the final 72 hours.

"They're totally committed and they're all in on getting back to the World Series," manager Bruce Bochy said of the front office. "It's not easy to keep a pitching staff intact. That's a lot of money. We want to win. That's the message that is being sent and we're doing all we can to get back and hopefully have a year like we had a couple years ago.

"That's our strength. In this division it's all about pitching in these ballparks. That's how we're going to win."

One of the big beneficiaries of Cain's deal could be Philadelphia's Cole Hamels, currently the top pitcher eligible for free agency after this season. Cain's contract also could give Lincecum momentum when potential talks begin about a long-term contract beyond his latest contract.

In addition, San Francisco catcher Buster Posey could do well down the road. He also is represented by CAA. Posey, the 2010 NL Rookie of the Year who is coming back from an injury-shortened season last year, is thrilled to see Cain stay.

"It's extremely exciting to know that Cainer is going to be around for another six years," Posey said. "It makes you feel good. He's such a huge part of what we do every day with his work ethic. The days he's not pitching he comes in and is working so hard. That stuff really rubs off on the rest of the guys."

The Giants weren't wary of making a significant financial commitment to Cain considering the $126 million, seven-year contract they gave struggling left-hander Barry Zito before the 2007 season.

"We're particularly pleased with this agreement because Matt's a homegrown player," Baer said. "He's a cornerstone of our pitching staff. Matt's a Giant in every way. He personifies what we want in this franchise."

Cain appreciates the Giants' commitment to keeping the pitchers in place on a roster ready to make another October run after missing the playoffs last season.

"It's something very rare that you see a lot of guys come through the same organization," Cain said. "It's been kind of cool we've been able to push each other. We like that and we've known each other for so long. It's nice Brian and Larry want to keep those guys together. There's a lot of chemistry that comes along with that."

Information from The Associated Press was used in this report.