The 31-year-old will attend big league spring training, which opens Feb. 19. He is 45-50 with a 4.26 ERA in nine seasons with Milwaukee, Toronto and the Chicago Cubs.
Villanueva was 5-7 with a 4.64 ERA in five starts and 37 relief appearances with the Cubs last season, striking out 72 in 77 2-3 innings. His career record as a reliever is 27-17 with a 3.55 ERA in 314 appearances.
St. Louis announced the agreement Wednesday.