Diaz played both at shortstop and third base for the Blue Jays last season, hitting .263 with a career-high 18 home runs, 26 doubles and 55 RBIs in 130 games. His production improved after the All-Star break, with a .290 batting average and OPS of .856 in the second half.
Prior to joining the Blue Jays, the 28-year-old Diaz played two seasons for the St. Louis Cardinals. He has a .275 career average with 42 home runs and 140 RBIs while also playing at second base and in the outfield.
"He's got some versatility, got some power and can do a lot of things," Astros general manager Jeff Luhnow told reporters. "It seems like it's an opportunity for us to improve our team. He can play short, he can play second, he can play a little bit of left, can play third. This is a guy about as versatile as any of the other guys on our roster.
"He's a good hitter, and we think he can be better. He's still coming into his prime."
Astros super-utility infielder Marwin Gonzalez is entering free agency.
Thornton, a 25-year-old right-hander, went 9-8 with a 4.42 ERA and 122 strikeouts in 22 starts for Triple-A Fresno this season.