Trent Williams and the San Francisco 49ers have reached a six-year, $138.06 million deal that will make him the highest-paid offensive lineman in NFL history, his agency announced Wednesday morning.

The deal has $55.1 million in guaranteed money, Williams’ agency Elite Loyalty Sports tweeted. The contract also includes a $30.1 million signing bonus, sources told ESPN’s Dianna Russini.

The Williams deal comes on the heels of the 49ers re-signing fullback Kyle Juszczyk and cornerback Jason Verrett. With that trio back in the fold, the Niners are expected to pursue free-agent center Alex Mack, a source told Russini.

Williams, whose deal surpasses the four-year, $92 million extension given to Green Bay Packers lineman David Bakhtiari in November, even tagged Mack in an Instagram post announcing his return. San Francisco is also expected continue to try to keep more of its own free agents, including nickel cornerback K’Waun Williams.

Williams, widely considered the best available free agent this offseason, previously discussed deals this week with the Kansas City Chiefs and Chicago Bears, sources told ESPN’s Adam Schefter.

But Kansas City signed Joe Thuney and Chicago signed Germain Ifedi, paving the way for Brown’s historic deal to return to San Francisco.

The 49ers traded for Williams on the third day of the 2020 NFL draft, sending a fifth-round selection and a 2021 third-round choice to the Washington Football Team.

Upon Williams joining the Niners, the team agreed to add a clause in his contract that meant it could not tag him this offseason. Williams went on to stabilize the left tackle position in place of the retired Joe Staley, starting 14 games and returning to his previous Pro Bowl form in the process.

Williams, who turns 33 in July, finished last season with the fourth-best pass block win rate (93.6%) among offensive tackles, according to ESPN metrics/NFL Next Gen Stats, trailing only Andrew Whitworth (94.2%), Duane Brown (94%) and Billy Turner (93.7%).

All of that came in Williams’ first season back after sitting out all of 2019 as he engaged in a dispute with Washington over the handling of his injury issues and his contract.

At the end of the season, Williams maintained that he hoped to re-sign with San Francisco but also acknowledged that he wanted to see what a premier tackle could get on the open market because players at his position of that caliber rarely make it that far into free agency.

“San Francisco would be the leading candidate,” Williams said in January. “So even if it does make it to free agency, it won’t be because I’m trying to go somewhere else. It may simply be because I want to see my value. It’s been 11 years in this league and I have yet to see a franchise left tackle go to the open market. I think it would be interesting to see what [my] value holds.”

Keeping Williams was the primary concern for the 49ers this offseason. Had they lost him, it would have meant a change a seismic shift in their plans for free agency and the draft.

Instead, the Niners have their blindside protector in place for six more years.

Since entering the league as the No. 4 overall pick in the 2010 draft, Williams has started 133 games, earning eight Pro Bowl berths and a second-team All-Pro nod in 2015. His eight Pro Bowl appearances are the most in the league for an offensive lineman since 2012.

Williams sat out the 2019 season because of a rare form of cancer and a dispute over the handling of his health and contract status in Washington.

ESPN’s Nick Wagoner contributed to this report.

The Kansas City Chiefs are 2019 NFC Champs - get your gear on at Fanatics