The deal is worth $35 million and includes a $13 million club option that could increase if an escalator clause in the contract vests, a source told ESPN.com's Jayson Stark. It replaces a one-year deal agreed to last month and includes a team option for 2020. San Diego essentially buys out one year of free agency and possibly two.
"These contracts make a lot of sense for both sides," general manager Josh Byrnes said. "In this case we potentially buy out two years of free agency. It's rare to do it so early, but Jedd, I think, he answered all the criteria you look at. First of all, character. This guy is a baseball player. I think he's going to be a part of us establishing the kind of winning tradition we want to have here. He's always hit and he's handled things that have been thrown at him."
Gyorko's guaranteed $35 million deal is the third-largest for a player with only one year of service time, trailing only Atlanta's Andrelton Simmons (seven years, $58 million) and Milwaukee's Ryan Braun (eight years, $45 million).
"I wanted to be a Padre," Gyorko said. "When they came to me and kind of showed the vision of what they have looking forward, it's something I want to be a part of. Be a part of a championship team. I think that's what we're going to be, hopefully soon, if not, definitely by the end of my contract."
Gyorko, 25, had a team-leading 23 home runs in 125 games last season, his first year in the majors.
"We are happy to sign Jedd and secure the rights to two free agent years," Byrnes said in a statement. "Jedd is a homegrown player in his fifth season with the Padres organization and has been a consistent performer every step of the way."
Gyorko's previous deal called for $510,900 this year in the major leagues and $294,000 in the minors. The new contract eliminates the lower minor league pay and adds salaries of $2 million in 2015, $4 million in 2016, $6 million in 2017, $9 million in 2018 and $13 million in 2019.
San Diego's 2020 club option is at $13 million with a $1 million buyout. The option can escalate a maximum of $2 million, and the buyout can escalate by up to $750,000, based on All-Star appearances and Top 10 MVP finishes by Gyorko between 2014 and 2019.
He has gotten off to a slow start this season, batting just .163 with one homer in his first 12 games.
While the Padres like Gyorko at second base, he played third base in the minor leagues and could move back to that position if Chase Headley leaves via free agency at the end of the season.
Gyorko said he'll play wherever the team wants him.
"I think he adjusted very well and people didn't realize how good he'd be there, so now it's a matter of maintaining that level," Byrnes said. "You never know how our rosters' going to shape up. We like him at second base. We like the competitive advantage of a second baseman who gives us this much offense. That was part of the attraction on the front end, and for now, I'd say that's the way we want it to end up as we go through the contract."
"It's a big commitment, but I think Jedd is worth it," Byrnes said. "When you place it through the age 30, 31 view, it's a risk we felt was worth taking."
ESPN's Keith Law and Buster Olney and The Associated Press contributed to this report.