The deal, which is worth $12 million this season and $9 million in 2020, is pending a physical.
Gonzalez, who played every position for the Houston Astros in 2018 except pitcher and catcher, was an invaluable spark plug during the Astros' rise to success, with manager A.J. Hinch calling him "my Swiss Army knife."
The switch-hitting Venezuelan played a career-high 145 games last season for Houston, hitting .247 with 16 home runs and 68 RBIs. He played mostly in left field and at the middle infield positions, with George Springer, Jose Altuve and Carlos Correa all missing time with injuries.
"He's a unique player because I can put him anywhere," Hinch said of Gonzalez during the 2018 postseason. "At any given point on any team, this guy can literally play six positions every day. ... As I've said before, he's the answer to everything. We have a problem, we insert Marwin, and no matter what, he steps up in a huge way."
There is not an obvious fit on Minnesota's roster for Gonzalez, who will turn 30 next month. The primary returning backup infielder for the Twins, Ehire Adrianza, hit .251 in 335 at-bats last season.
Minnesota just reached a five-year, $25.75 million contract with shortstop Jorge Polanco, and second baseman Jonathan Schoop ($7.5 million) and first baseman C.J. Cron ($4.8 million) were added this offseason to fill the right side of the infield. Third baseman Miguel Sano, an All-Star in 2017, is still seen as a potential franchise cornerstone, though his career has been beset by injuries.
Meanwhile, left fielder Eddie Rosario was the team MVP last year, and right fielder Max Kepler just got a five-year, $35 million contract. Even the designated hitter at-bats are largely spoken for, with five-time All-Star Nelson Cruz the highest-profile addition of the offseason for Minnesota.
Gonzalez made $3.725 million with the Astros in 2018 -- his seventh season with the team. For his career, he has a .264 batting average with 76 home runs and 292 RBIs.
He saved his best hitting for the pennant race. After posting a .660 OPS through July, Gonzalez registered an .875 OPS from August on, the third-best mark on the team. He led Houston in the postseason with nine RBIs and was second to Springer in batting average (.333), hits (11), home runs (2) and total bases (19).
"Being able to pick his brain the past two years has been beneficial for me because we've always had that role player," Astros utilityman Tony Kemp said. "You're in there, you get hot, and then you have to sit for three games. Being able to talk with Marwin, he's one of my favorite guys in the clubhouse just because he brings that passion to the game every day. I can't say enough good things about him."
ESPN's Marly Rivera and The Associated Press contributed to this report.