Financial terms weren't disclosed, but a league source told ESPN's Adam Caplan that Celek's deal is worth a total of $14 million, with $4.5 million guaranteed.
The contract breaks down to an average of $2.5 million per season, the source said.
Celek, whose 2015 season ended after 11 games because of an ankle injury, has a bit of a connection to new Niners coach Chip Kelly. Kelly coached Celek's older brother, Brent, also a tight end, with the Philadelphia Eagles.
"Since Garrett entered the league as an undrafted rookie free agent in 2012, he has displayed the skill, work ethic and desire to compete at a high level in the National Football League," Niners general manager Trent Baalke said in a statement. "His commitment and determination to succeed are reflected in the way he conducts himself as a professional on and off the field. As an organization, we would like to congratulate Garrett and look forward to his continued development as a member of this organization."
A Michigan State product, Celek, 27, had a career-high 19 catches for 186 yards and three touchdowns in eight starts last season. While he was considered the 49ers' pass-catching tight end, with Vance McDonald viewed as the blocker, Celek had only four catches after starter Vernon Davis was traded to the Denver Broncos.
In his four-year career, Celek has 27 catches for 328 yards and the three TDs in 39 games, 10 of them starts.
McDonald, meanwhile, was a second-round pick of the 49ers in 2013 and started 11 of the 14 games he played, setting career highs in catches (30), receiving yards (326) and touchdown catches (3).
Blake Bell, the other tight end on the Niners' roster, started five of the 14 games he played as a rookie last season. He finished with 15 receptions for 186 yards.
The Niners waived tight end Brian Leonhardt on Monday.