Adam Schefter reveals how the 49ers became interested in John Lynch for GM and says San Francisco plans to offer Kyle Shanahan a six-year deal to be head coach after the Super Bowl. (1:42)

The San Francisco 49ers have hired Hall of Fame candidate and Fox analyst John Lynch to be their general manager, the team announced Sunday night.

Sources told ESPN that the deal is for an almost unprecedented six years.

Less than a week before he is eligible to be voted into the Pro Football Hall of Fame, the former Stanford standout is returning to the Bay Area.

As the 49ers are signing Lynch to a six-year contract, the plan is to offer Atlanta Falcons offensive coordinator Kyle Shanahan a six-year contract to be their head coach, according to league sources. The 49ers' idea always was to have the head coach and general manager jobs tied together in terms of length of contract.

Lynch spent Thursday and Friday meeting with San Francisco officials. He spent Thursday night at 49ers owner Jed York's house, before the team flew him to San Diego on Friday night so he could attend a family function.

Lynch accepted the job on Sunday.

He has no front-office experience, but he has been connected to front-office jobs in the past. Some in Denver thought he could have been a candidate to replace John Elway one day, though that never materialized.

York told MMQB on Sunday night that he was willing to take a chance by giving Lynch his first front-office job and referenced Shanahan's input in the decision.

"So many opportunities are missed in the NFL because people don't want to do something different," York said. "We're OK with that, because I am confident in Kyle and John. John has watched John Elway and how he's built a team in Denver. As easy as it is to say he hasn't built a team yet -- I get that -- I talk to Kyle, and he says John is the most prepared of all the TV [people] he meets in the production meetings before games.

"We understand we'll have to live with growing pains, but I'm willing to do that because I believe the upside with both of them is so great."

The idea to hire Lynch was his own. He personally called Shanahan and volunteered for the job about a week ago.

Shanahan, expected to be named the Niners' coach after the Super Bowl, thought about Lynch, and the more he thought about it, the more he felt Lynch was a fit for the job. Lynch played for Shanahan's father, Mike, in Denver.

The 49ers confirmed that they had interviews with nine general manager candidates after firing Trent Baalke on Jan. 1, none of which were with Lynch. They narrowed that group down to four, and it then came down to two, after Green Bay Packers executives Brian Gutekunst and Eliot Wolf removed themselves from consideration.

From there, York and executive Paraag Marathe had second interviews with Arizona Cardinals vice president of player personnel Terry McDonough and Minnesota Vikings assistant general manager George Paton over the weekend.

Throughout the process, the Niners acknowledged that they would keep an open mind, but their primary goal was to find someone who could work in lockstep with Shanahan.

"We need to make sure that the head coach and the general manager know each other, have a good understanding for each other," York said at the beginning of the process. "It doesn't mean that they had to have worked together in the past, but they have to have a good respect for each other and a good understanding and know that they have similar visions and philosophies on building a football team."

ESPN's Nick Wagoner contributed to this report.