Houston sent right-hander Corbin Martin, right-hander J.B. Bukauskas, first baseman Seth Beer and infielder Josh Rojas to Arizona to complete the deal.
"Zack Greinke's one of the best pitchers in baseball. We had him high on our list," Astros general manager Jeff Luhnow said. "We didn't know if this was even remotely possible, and it really wasn't until the last 48 hours, really the last 24 hours that we started to get traction on something. [Astros owner Jim Crane] supported us and agreed that we could make the appropriate investment dollar-wise, and it became a matter of finding the right prospects, the right mix of players, to go back.
"We really don't have any holes right now. If we stay healthy, this team is as good as any team I've ever seen."
Cole said that when the players learned of the deal, there was "a lot of hooting and hollering at 4:07. We are ecstatic. We're getting a Hall of Fame pitcher, a craftsman."
After news of the deal, Houston moved to plus-275 to win the World Series -- tied with the Los Angeles Dodgers for the shortest odds -- and plus-135 to win the American League, moving ahead of the New York Yankees at Caesars Sportsbook. Before the trade, the Astros were plus-450 to win the World Series and plus-200 to win the AL; New York was plus-140).
The Diamondbacks moved to replace Greinke in the rotation by acquiring right-handed starter Mike Leake from the Seattle Mariners. Leake was 9-8 with a 4.27 ERA this season for Seattle. He is in the fourth year of a five-year, $80 million contract.
Greinke is 10-4 with a 2.90 ERA in 23 starts this season. Entering Wednesday, the right-hander, who won an AL Cy Young Award with the Kansas City Royals in 2009, was 197-122 with a 3.36 ERA in 16 major league seasons.
He pitched against the Yankees on Wednesday, striking out seven batters in five innings. Greinke left the ballpark without commenting to reporters.
Before the team confirmed the deal, Astros manager AJ Hinch didn't want to show too much excitement while knowing he was getting one of baseball's most consistent pitchers.
"I know he's an Astro," Hinch said. "I know he's really good. I don't know him personally, but I'm going to get to know him. We acquired him because of how good he is. Certainly we expect him to be a big part of our push to win the division and keep winning into October. He's an incredible pitcher."
For Houston's rotation, it's a case of the rich getting richer. Before the Greinke trade, Astros starters ranked first in the majors in both strikeouts per nine innings (10.5) and opponents' batting average (.213). Their ERA (3.68) ranked fourth. Verlander leads the AL in wins (14) and ERA (2.73), and Cole tops the majors with 212 strikeouts.
Verlander, who won the AL Cy Young in 2011 while with the Detroit Tigers, expressed excitement about the Greinke deal.
Wow... that escalated quickly! 🔥🔥🔥 @astros— Justin Verlander (@JustinVerlander) July 31, 2019
Cole credited Crane, Luhnow and the front office for their hard work in making the trade happen.
"What a pickup," Cole said. "They nailed it. They did a magnificent job."
Luhnow said he believes Greinke's low-key personality will thrive in Houston.
"I don't know him personally, but I think he's not a guy that seeks the limelight, and that actually works well for us here in Houston," the GM said. "And slotting in with Verlander and Cole, he's gonna not have to be the guy that's in front of the camera the whole time."
Luhnow said it was difficult to give up four top prospects to snag Greinke but that he and Crane believed they needed to be aggressive to upgrade this team, even though it has a comfortable eight-game lead atop the AL West.
"Every year going forward there's going to be multiple good players reaching free agency, so you just don't know when you're going to assemble a group this talented again," Luhnow said. "So you have to take advantage of that, and that's something Jim believes in and so do I. It's a balancing act ... but we are definitely going for it this year."
Greinke gives the Astros insurance after this season in case Cole leaves in free agency. Greinke is in the fourth year of a six-year, $206.5 million deal that he signed with Arizona prior to the 2016 season.
As part of the trade, the Diamondbacks are sending $24 million to the Astros, who will be responsible for the remaining $53 million on the deal, sources confirmed to ESPN's Jeff Passan.
The Associated Press contributed to this report.