After an offseason in which a divorce seemed all but certain, the San Francisco 49ers and quarterback Jimmy Garoppolo are staying together for one more season.

Garoppolo and the Niners agreed to a restructured one-year contract that is worth $6.5 million in fully guaranteed base salary.

The new-look deal contains another total of $500,000 in roster bonuses and playtime bonuses that could boost it by another nearly $9 million for up to a total of $16 million if all bonuses are reached.

Garoppolo's restructured contract also includes a no-trade and no-tag clause that ensures Garoppolo will serve as the backup to Trey Lance this season and will then be able to explore unrestricted free agency in 2023.

A source told ESPN's Jeremy Fowler that Garoppolo and the 49ers have discussed the option of waiving the no-trade clause if something develops and the 49ers can get compensation, but Garoppolo was willing to help the team and wanted to play again this season with his teammates.

Depending on how it's structured, Garoppolo's salary cap number for 2022 will end up being somewhere between $18 million to 19 million less than the $26.9 million it was previously slated to cost.

Garoppolo had right shoulder surgery in March, which made trading him nearly impossible, and by the time he resumed throwing in late June, most quarterback-needy teams had already gone a different direction.

Now, the Niners have one of the most expensive backup quarterbacks in the league but also one who knows the offense and has been under center for a trip to Super Bowl LIV and last year's run to the NFC Championship Game.

In games started by quarterbacks other than Garoppolo since Shanahan's arrival in 2017, the Niners are 8-28. They're 35-16 with Garoppolo at the controls.