Third baseman Rafael Devers and the Boston Red Sox are finalizing an 11-year, $331 million contract extension, a deal that will keep the 26-year-old star from reaching free agency this year and constitutes the longest and largest guarantee ever given by the franchise.

The agreement, which is expected to be signed Wednesday night and would be the largest ever for a third baseman, comes in the midst of an arduous winter for the Red Sox, who lost longtime shortstop Xander Bogaerts to San Diego in free agency nearly three years after trading star right fielder Mookie Betts to the Los Angeles Dodgers. Offering Devers to a deal far longer than Manny Ramirez’s eight-year pact and more than 50% larger than David Price’s $217 million contract was enough for the two-time All-Star to accept shepherding the Red Sox out of last place in the American League East and back to contention.

The contract will start in 2023 and extend through the 2033 season, sources said. The one-year, $17.5 million contract Devers signed earlier in the week to avoid arbitration will be superseded by the long-term deal.

Devers debuted with Boston at 20 years old in 2017 and quickly illustrated why scouts so adored his bat. His left-handed swing was perfectly suited for Fenway Park, with doubles thwacking off the Green Monster and home runs carrying out to right field. Devers’ acumen has only grown. In 2022, he hit .295/.358/.521 with 27 home runs, 88 RBIs and a career-best OPS+ of 141.