He spent the first six years of his career with the Minnesota Twins.
Financial terms were not disclosed.
Ortiz likely will be used as a designated hitter and a backup at first base for Jeremy Giambi, who was signed by the Red Sox last month at the winter meetings.
"All of our scouts think, and our analysis dictates, that David has a very high ceiling," General Manager Theo Epstein told MLB.com, the official Web site of Major League Baseball. "Due to injuries, he hasn't necessarily reached his ceiling. You're looking at a player who can be an impact middle of the lineup bat. An everyday player. That is his ceiling and we hope he reaches it with us."
Ortiz, 27, is coming off his best season, posting career highs in home runs (25) and RBI (75) while batting .272 with a .339 on-base percentage and a .500 slugging percentage in 125 games.
He was used primarily as the DH by the Twins, appearing in only 15 contests at first base. In 132 career games at the position, Ortiz had a fielding percentage of .991.
"When I was with Minnesota, I had a lot of injuries and I started DH-ing," Ortiz said. "But at the same time, I'm just 27 years old. I'm working out hard this winter to see if I can be an everyday first baseman. I think that if I stay healthy, I can put up some numbers that can help Boston go to the playoffs and win a World Series. That's my goal right now. I'm looking forward to playing 160 games in the big leagues. I haven't done that yet."
In 455 games for the Twins, Ortiz batted .266 with 58 homers and 238 RBI. He was limited to 89 games in 2001 by a fractured right wrist.