He joins a fearsome rotation that includes Justin Verlander and Gerrit Cole.
The Astros also acquired right-handers Aaron Sanchez and Joe Biagini from the Toronto Blue Jays, according to multiple reports.
The Diamondbacks acquired moved to replace Greinke in the rotation by acquiring right-handed starter Mike Leake from the Seattle Mariners, sources told Passan.
Leake is 9-8 with a 4.40 ERA this season for Seattle. He is in the fourth year of a five-year, $80 million contract.
Greinke is 10-4 this season with a 2.87 ERA in 22 starts. The right-hander, who won a Cy Young award with the Kansas City Royals in 2009, is 197-122 with a 3.36 ERA in 16 major league seasons.
He pitched against the New York Yankees on Wednesday, striking out seven batters in five innings.
Greinke gives the Astros insurance for after this season in case Cole leaves in free agency. Greinke is signed through the 2021 season, scheduled to be paid $32 million in '20 and '21.
BREAKING: Greinke to Astros, source tells ESPN.— Jeff Passan (@JeffPassan) July 31, 2019
Corbin Martin, J.B. Bukauskas, Seth Beer and Josh Rojas are headed to the Diamondbacks for Zack Greinke, source tells ESPN.— Jeff Passan (@JeffPassan) July 31, 2019
SEE ALSO: Astros trade Tony Kemp to Cubs for Martin Maldonado