SANTA CLARA, Calif. -- It required time and patience, but the San Francisco 49ers finally got their man.

The Niners announced Monday that they have officially hired Atlanta offensive coordinator Kyle Shanahan to be their head coach. The deal is expected to run for six years, matching the contract the 49ers gave new general manager John Lynch. Shanahan becomes the team's fourth coach in as many years, replacing Chip Kelly, who followed Jim Tomsula and Jim Harbaugh.

For Shanahan, becoming a head coach is the realization of a dream.

"As a young man, I had the unique benefit of being exposed to the storied history of the San Francisco 49ers firsthand,'' Shanahan said in a statement. "From that exposure, I developed great respect for those who created a world-class, championship standard. As this team begins the task of re-establishing that standard, I could not ask for a better partner than John Lynch. He is a man who certainly has personal knowledge of what championship organizations look like. John and I look forward to establishing a strong culture that will serve as our foundation for constructing this team.''

In the process, the Niners became the last of the six teams with head-coach openings to make a hire. It was a deal 36 days in the making.

The 49ers fired Kelly on Jan. 1 and first interviewed Shanahan on Jan. 6 while the Falcons were enjoying a bye week for the wild-card round. The Niners interviewed him again during the bye week before the Super Bowl, also talking to Lynch and two other general manager candidates in the process.

But the Niners couldn't hire Shanahan until his season ended. That happened Sunday when the Falcons lost in devastating fashion to the New England Patriots in Super Bowl LI. Atlanta blew a 25-point second-half lead, with Shanahan's playcalling late in the game coming under scrutiny.

Kyle Shanahan and the Falcons jumped out to a big lead but couldn't close out New England in Super Bowl LI. Jason Getz/USA TODAY Sports

"It's not really the run-pass ratio that I look at,'' Shanahan told reporters of his decision to keep throwing after getting into field goal range late in the fourth quarter. "It's you stay on the field and you run your offense. We went three-and-out two times, which was huge. I think we had second-and-1 on both of those. To not convert on second-and-1 and then third, it was tough. That's why we let them get back into the game.''

San Francisco moved swiftly after Atlanta lost to meet with Shanahan and finalize a contract that had been expected since New England offensive coordinator Josh McDaniels removed himself from consideration on Jan. 16.

"As an offensive mind, I think he stands alone in the National Football League, as evidenced by the explosive and record-setting offense in Atlanta,'' Lynch said. "Though he grew up around coaching, what has most impressed me about Kyle is that he's become his own man in the profession. Our philosophies on football and our visions for leading the 49ers back to being a championship team align in every way. I am thrilled to have Kyle Shanahan on board.''

While the 49ers waited for Shanahan, they watched as all of their other candidates took jobs elsewhere or pulled out of the hunt. The Los Angeles Rams hired Sean McVay; the Los Angeles Chargers chose Anthony Lynn; and the Buffalo Bills reeled in Sean McDermott. When McDaniels stepped aside and the Niners focused their attention on Shanahan, Seattle assistant head coach Tom Cable also opted out.

Shanahan was one of the most coveted coaching candidates in the league this offseason, interviewing with Denver and Jacksonville and having a meeting with the Rams postponed because of weather. All three teams hired coaches before Shanahan was eligible to agree to a deal.

At 37, Shanahan becomes the second-youngest coach in the NFL; only the 31-year-old McVay is younger. But Shanahan's experience belies his youth.

Shanahan was the youngest position coach in the NFL in 2006 when he coached receivers for the Houston Texans, and two years later he was promoted to become the youngest offensive coordinator in the league.

In the time since, Shanahan has spent nine years as a coordinator, with stops in Houston, Cleveland, Washington and Atlanta. In six of those nine seasons, Shanahan has called plays for an offense that finished in the top nine in the league in yards per game.

Shanahan's finest work came this season when Atlanta led the league in points scored (540) and yards per play (6.7) and was second in yards per game (415.8). That performance earned Shanahan the Pro Football Writers of America's Assistant Coach of the Year award, and quarterback Matt Ryan won the league MVP award.

While Shanahan has never coached in San Francisco, he's no stranger to the organization. His father Mike was the offensive coordinator for the Niners from 1992 to 1994, pressing the buttons of an offense that led the franchise to its most recent Super Bowl triumph in 1994 before becoming the head coach of the Denver Broncos.

Speaking to NFL Network before Saturday's NFL honors show, 49ers CEO Jed York couldn't name Shanahan because of league tampering rules, but York said he was rooting for the Falcons and made it clear what he expects of Shanahan and Lynch in their new roles.

"I hate the term rebuilding because it gives people a built-in excuse," York said. "What we're trying to do is re-establish our culture, and we want to be at a championship level. John Lynch brings that. You can certainly guess as to who the new head coach is going to be, but we certainly believe that the new head coach will bring a legacy of the 49ers, a legacy of great football knowledge, and those two should be able to work together in a way that we should have a long run of success. That, to me, is the biggest thing. I don't care about going from 2-14 to whatever the record is this year. I care about 20 years from now when we look back, what did we do together, what did we accomplish over that period of time."