The 52-year-old Kelly, who was fired in his third season as coach of the Philadelphia Eagles with one week to go in the regular season, will receive a four-year deal worth $24 million from the 49ers, a league source told ESPN NFL Insider Adam Schefter.
Kelly had interviewed with the 49ers last week.
"As one of the most historic franchises in the National Football League, I realize the high standards and expectations that this position demands and I embrace the challenges ahead," Kelly said in a statement. "My immediate focus is to build the best coaching staff possible, one that will maximize the abilities of each of our players and put us in the best position to win football games."
49ers CEO Jed York tweeted that he and general manager Trent Baalke selected Kelly, who will be introduced in a news conference next week, "after a thorough search."
Wide receiver Torrey Smithalso tweeted about the hiring Thursday.
Kelly fits the criteria set forth by York and Baalke as a veteran coach with a big name and a clear vision -- a quick-strike offensive philosophy. It should be interesting to see how Kelly, who wanted a big say in personnel control in Philadelphia, interacts with Baalke, who, despite saying there is no iron fist in the organization, has a reputation as a personnel hard-liner.
"Chip possesses all the qualities we were looking for in our next head coach," Baalke said in a statement. "He has demonstrated the ability to be innovative everywhere he has coached and has had great success throughout his career. Chip's passion for the game and vision for the future of this team clearly stood out to us during the search process. He is an extremely driven individual that I look forward to working with."
Kelly, who went to Philadelphia after four seasons as coach at Oregon, had consecutive 10-6 seasons with the Eagles before this season's flameout, which began with controversy over his handling of the roster.
He is just the second 49ers head coach since the 1970 AFL-NFL merger who has had previous NFL head-coaching experience (not counting Tomsula, who was an interim coach for one game before his hire). The other was Dennis Erickson, who went 9-23 in 2003 and 2004.
Kelly already has a connection with Niners senior personnel executive Tom Gamble, who had been with Kelly in Philadelphia.
Kelly was the first coach in Eagles history (and second in NFL history) to win a division title in his first season -- Philadelphia lost a wild-card round game to the New Orleans Saints -- and his 26 wins are tied with Ray Rhodes for third most by an Eagles coach in his first three seasons.
The Eagles averaged a play once every 23.1 seconds of possession under Kelly, three seconds faster than any other team, per ESPN Stats & Information.
Philadelphia owes Kelly about $13 million over the next two years, but that total will be offset by the deal Kelly signs with San Francisco, a league source told ESPN's Darren Rovell.
Being an offensive-minded coach, Kelly fits the same bill as the seven candidates the Niners interviewed after they finished 31st in the league in total offense and last in scoring: Buffalo Bills assistant head coach/running backs coach Anthony Lynn, Cleveland Browns offensive coordinator John DeFilippo, Tampa Bay Buccaneers offensive coordinator Dirk Koetter, Cincinnati Bengals offensive coordinator Hue Jackson, former New York Giants coach Tom Coughlin and former Denver Broncos and Washington coach Mike Shanahan.
"Chip has a proven track record at both the college and NFL levels that speaks for itself," York said in a statement. "We believe strongly that he is the right man to get this team back to competing for championships. I look forward to watching Trent and Chip work closely to build a team that will make us all proud."
The 49ers had narrowed their finalists to Kelly and Shanahan earlier Thursday, sources told ESPN NFL Insider Adam Schefter.
Kelly's may also offer possibilities for quarterbackColin Kaepernick, who is recovering from three surgeries -- left shoulder, right thumb and left knee -- and who was thought to be done in Santa Clara but whose skillset fits Kelly's offense.
Kaepernick's $11.9 million salary for 2016 becomes fully guaranteed for injury come April 1, and many had believed the team might try to trade or release him.
The Associated Press contributed to this report.
Schefter: Kelly is the 'anti-Tomsula'
The NFL Insiders crew explains why the 49ers decided to hire Chip Kelly and discusses the amount of say he will have in personnel.
Polian: Kelly 'the right fit' for 49ers
Bill Polian joins Russillo & Kanell to break down the 49ers hiring Chip Kelly to be their head coach and what effect Kelly will have on Colin Kaepernick.