Gonzalez, 31, spent the past two seasons with the Minnesota Twins. He hit .211 with five home runs and 22 RBIs last year in a pandemic-shortened schedule.
Before his stint in Minnesota, he played seven seasons with the Houston Astros. His best season was in 2017, when he hit .303/.377/.530 with 23 homers and 90 RBIs and helped the team win the World Series.
A switch-hitter known for his defensive versatility, Gonzalez played first base, second base, third base and right field for the Twins last season.
Boston's agreement with Gonzalez, which was first reported by MLB.com, comes a day after the Red Sox traded Andrew Benintendi to the Kansas City Royals in a three-team deal that yielded outfielder Franchy Cordero and two players to be named later.